更新到0.6.0.2

This commit is contained in:
2026-07-06 08:47:33 +08:00
parent e29a5178b7
commit 97d41a1385
473 changed files with 156342 additions and 5 deletions
@@ -0,0 +1,3 @@
{
"reference": "GUID:4cba057b890ab8f49bdbfaa6f02fc72c"
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: fb976d5e51c5a1f448390889bfdabc47
AssemblyDefinitionReferenceImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,588 @@
namespace DrawXXL
{
using UnityEngine;
using System;
#if UNITY_EDITOR
using UnityEditor;
[CustomEditor(typeof(DrawXXLChartInspector))]
public class DrawXXLChartInspector_Inspector : Editor
{
DrawXXLChartInspector theDrawXXLChartInspector_unserializedMonoB;
GUIContent checkmarkSymbol;
GUIContent crossSymbol;
GUIContent magnifierGlassSymbol_atXAxis;
GUIContent magnifierGlassSymbol_atYAxis;
GUIContent magnifierGlassSymbol_forBothAxes;
GUIContent handSymbol_atXAxis;
GUIContent handSymbol_atYAxis;
GUIContent handSymbol_forBothAxes;
float travelledWorldSpaceDistanceAlongSliderDirection_sinceMouseDown_for_zoomXAxisHandle = 0.0f;
float travelledWorldSpaceDistanceAlongSliderDirection_sinceMouseDown_for_zoomYAxisHandle = 0.0f;
float travelledWorldSpaceDistanceAlongSliderDirection_sinceMouseDown_for_forZoomBothAxesHandle = 0.0f;
float travelledWorldSpaceDistanceAlongSliderDirection_sinceMouseDown_for_dragXAxisHandle = 0.0f;
float travelledWorldSpaceDistanceAlongSliderDirection_sinceMouseDown_for_dragYAxisHandle = 0.0f;
float travelledWorldSpaceDistanceAlongChartsXDirection_sinceMouseDown_for_unifiedDragHandle = 0.0f;
float travelledWorldSpaceDistanceAlongChartsYDirection_sinceMouseDown_for_unifiedDragHandle = 0.0f;
float sizeFactor_forBacksnappingConeCaps = 1.0f;
float sizeFactor_forBacksnappingCylinderCaps = 0.8f;
float sizeFactor_forBacksnappingSphereCaps = 1.0f;
float distanceFromAnchorPosFactor_forBacksnappingConeCaps = -0.5f;
float distanceFromAnchorPosFactor_forBacksnappingCylinderCaps = -1.7f;
float sizeFactor_forCheckmarkIcon = 0.5f;
float sizeFactor_forCrossIcon = 0.5f;
float sizeFactor_forHandIcon_onConesAndSpheres = 0.42f;
float sizeFactor_forMagnifierGlassIcons_onCylinders = 0.5f;
void OnEnable()
{
theDrawXXLChartInspector_unserializedMonoB = (DrawXXLChartInspector)target;
//credits to https://github.com/Zxynine/UnityEditorIcons
string tooltip_forCheckbox = "If this is selected then the axis scaling will be automatically updated, so that all active lines are always fully displayed, also if new values are added." + Environment.NewLine + Environment.NewLine + "This setting gets auto-deactivated as soon as you drag one of the manual scale sliders.";
checkmarkSymbol = EditorGUIUtility.IconContent("FilterSelectedOnly@2x", tooltip_forCheckbox);
crossSymbol = EditorGUIUtility.IconContent("winbtn_win_close@2x", tooltip_forCheckbox);
magnifierGlassSymbol_atXAxis = EditorGUIUtility.IconContent("ViewToolZoom@2x", "Drag this to zoom only the X axis.");
magnifierGlassSymbol_atYAxis = EditorGUIUtility.IconContent("ViewToolZoom@2x", "Drag this to zoom only the Y axis.");
magnifierGlassSymbol_forBothAxes = EditorGUIUtility.IconContent("ViewToolZoom@2x", "Drag this to zoom both axes.");
handSymbol_atXAxis = EditorGUIUtility.IconContent("ViewToolMove@2x", "Drag this to scroll only the X axis.");
handSymbol_atYAxis = EditorGUIUtility.IconContent("ViewToolMove@2x", "Drag this to scroll only the Y axis.");
handSymbol_forBothAxes = EditorGUIUtility.IconContent("ViewToolMove@2x", "Drag this to scroll both axes.");
}
public void OnSceneGUI()
{
if (theDrawXXLChartInspector_unserializedMonoB.hideHandles_andInsteadUseInspectorSlidersForZoomAndScroll == false)
{
theDrawXXLChartInspector_unserializedMonoB.TryNote_chartWorldSpacePosRotScale_beforeChangingItToScreenspace();
try
{
if (theDrawXXLChartInspector_unserializedMonoB.theChartIsDrawnInScreenspace) { UtilitiesDXXL_ChartDrawing.SetPosRotScaleOfChart_toScreenspace(theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo, theDrawXXLChartInspector_unserializedMonoB.screenSpaceTargetCamera, theDrawXXLChartInspector_unserializedMonoB.chartWidth_isDefinedRelTo_cameraWidth_notCameraHeight, true); }
DrawCursorSliders();
float sizeOfHandleCaps = theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.xAxis.Get_fixedConeLength_forBothAxisVectors();
DrawScrollSliderAsConeAtXAxis(sizeOfHandleCaps);
DrawScrollSliderAsConeAtYAxis(sizeOfHandleCaps);
DrawScrollSliderAsSphereAtUnifiedAxis(sizeOfHandleCaps);
DrawZoomSliderAsCylinderAtXAxis(sizeOfHandleCaps);
DrawZoomSliderAsCylinderAtYAxis(sizeOfHandleCaps);
DrawZoomSliderAsCylinderAtUnifiedAxis(sizeOfHandleCaps);
DrawCheckboxFor_showAllValues(sizeOfHandleCaps);
}
catch { }
theDrawXXLChartInspector_unserializedMonoB.TrySetBack_chartWorldSpacePosRotScale_afterUsingItInScreenspace();
}
}
void DrawCursorSliders()
{
DrawACursorSlider(true, true);
}
void DrawACursorSlider(bool isAtLowerEndOfCursorsVertLine_notAtUpperEnd, bool tryOtherCursorSlider_ifThisCursorSliderDoesntReportAnyChange)
{
float worldSpaceDistanceAlongXAxis_measuredFromYAxis_beforeDrag = theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.Width_inWorldSpace * theDrawXXLChartInspector_unserializedMonoB.curr_cursorPosition_as0to1OfChartWidth;
EditorGUI.BeginChangeCheck();
float worldSpaceDistanceAlongXAxis_measuredFromYAxis_afterDrag = InternalDXXL_ChartHandles.CursorSlider(isAtLowerEndOfCursorsVertLine_notAtUpperEnd, worldSpaceDistanceAlongXAxis_measuredFromYAxis_beforeDrag, theDrawXXLChartInspector_unserializedMonoB);
bool hasChanged = EditorGUI.EndChangeCheck();
if (hasChanged)
{
UpdateCursorPos0to1(worldSpaceDistanceAlongXAxis_measuredFromYAxis_afterDrag);
}
else
{
if (tryOtherCursorSlider_ifThisCursorSliderDoesntReportAnyChange)
{
DrawACursorSlider(!isAtLowerEndOfCursorsVertLine_notAtUpperEnd, false);
}
}
}
void UpdateCursorPos0to1(float worldSpaceDistanceAlongXAxis_measuredFromYAxis_afterDrag)
{
float new_cursorPosition_as0to1OfChartWidth = worldSpaceDistanceAlongXAxis_measuredFromYAxis_afterDrag / theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.Width_inWorldSpace;
theDrawXXLChartInspector_unserializedMonoB.ForceCursorSliders_toFitGiven0to1XPos(new_cursorPosition_as0to1OfChartWidth);
}
void DrawScrollSliderAsConeAtXAxis(float sizeOfHandleCaps)
{
float distanceFromAnchorPos = distanceFromAnchorPosFactor_forBacksnappingConeCaps * sizeOfHandleCaps;
Vector3 sliderDirection_worldSpace_normalized = theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.xAxis.AxisVector_normalized_inWorldSpace;
Vector3 restingPosition = theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.Position_worldspace + theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.xAxis.AxisVector_inWorldSpace + sliderDirection_worldSpace_normalized * distanceFromAnchorPos;
Handles.CapFunction capFunction = Handles.ConeHandleCap;
float capSizeScaleFactor = sizeFactor_forBacksnappingConeCaps;
GUIContent icon = handSymbol_atXAxis;
float iconSizeFactor = sizeFactor_forHandIcon_onConesAndSpheres;
Vector2 iconPositionOffset_inScreenspace_relToHandleCapSize = new Vector2(-0.45f, 0.2f); //-> manually shifting the icon, so it appears centered over the handle cap.
EditorGUI.BeginChangeCheck();
travelledWorldSpaceDistanceAlongSliderDirection_sinceMouseDown_for_dragXAxisHandle = InternalDXXL_ChartHandles.OneDirectionalBacksnapSlider(travelledWorldSpaceDistanceAlongSliderDirection_sinceMouseDown_for_dragXAxisHandle, restingPosition, theDrawXXLChartInspector_unserializedMonoB, sliderDirection_worldSpace_normalized, capFunction, capSizeScaleFactor, icon, iconSizeFactor, iconPositionOffset_inScreenspace_relToHandleCapSize, false, false);
bool hasChanged = EditorGUI.EndChangeCheck();
if (hasChanged)
{
theDrawXXLChartInspector_unserializedMonoB.alwaysEncapsulateAllValues = false;
theDrawXXLChartInspector_unserializedMonoB.scrollSinceMouseDown_fromOnlyXDimHandleSlider_asTravelledWorldSpaceDistanceAlongSliderDirection = travelledWorldSpaceDistanceAlongSliderDirection_sinceMouseDown_for_dragXAxisHandle;
}
else
{
if (GUIUtility.hotControl == 0)
{
travelledWorldSpaceDistanceAlongSliderDirection_sinceMouseDown_for_dragXAxisHandle = 0.0f;
theDrawXXLChartInspector_unserializedMonoB.scrollSinceMouseDown_fromOnlyXDimHandleSlider_asTravelledWorldSpaceDistanceAlongSliderDirection = 0.0f;
}
}
}
void DrawScrollSliderAsConeAtYAxis(float sizeOfHandleCaps)
{
float distanceFromAnchorPos = distanceFromAnchorPosFactor_forBacksnappingConeCaps * sizeOfHandleCaps;
Vector3 sliderDirection_worldSpace_normalized = theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.yAxis.AxisVector_normalized_inWorldSpace;
Vector3 restingPosition = theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.Position_worldspace + theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.yAxis.AxisVector_inWorldSpace + sliderDirection_worldSpace_normalized * distanceFromAnchorPos;
Handles.CapFunction capFunction = Handles.ConeHandleCap;
float capSizeScaleFactor = sizeFactor_forBacksnappingConeCaps;
GUIContent icon = handSymbol_atYAxis;
float iconSizeFactor = sizeFactor_forHandIcon_onConesAndSpheres;
Vector2 iconPositionOffset_inScreenspace_relToHandleCapSize = new Vector2(-0.23f, 0.0f); //-> manually shifting the icon, so it appears centered over the handle cap.
EditorGUI.BeginChangeCheck();
travelledWorldSpaceDistanceAlongSliderDirection_sinceMouseDown_for_dragYAxisHandle = InternalDXXL_ChartHandles.OneDirectionalBacksnapSlider(travelledWorldSpaceDistanceAlongSliderDirection_sinceMouseDown_for_dragYAxisHandle, restingPosition, theDrawXXLChartInspector_unserializedMonoB, sliderDirection_worldSpace_normalized, capFunction, capSizeScaleFactor, icon, iconSizeFactor, iconPositionOffset_inScreenspace_relToHandleCapSize, false, false);
bool hasChanged = EditorGUI.EndChangeCheck();
if (hasChanged)
{
theDrawXXLChartInspector_unserializedMonoB.alwaysEncapsulateAllValues = false;
theDrawXXLChartInspector_unserializedMonoB.scrollSinceMouseDown_fromOnlyYDimHandleSlider_asTravelledWorldSpaceDistanceAlongSliderDirection = travelledWorldSpaceDistanceAlongSliderDirection_sinceMouseDown_for_dragYAxisHandle;
}
else
{
if (GUIUtility.hotControl == 0)
{
travelledWorldSpaceDistanceAlongSliderDirection_sinceMouseDown_for_dragYAxisHandle = 0.0f;
theDrawXXLChartInspector_unserializedMonoB.scrollSinceMouseDown_fromOnlyYDimHandleSlider_asTravelledWorldSpaceDistanceAlongSliderDirection = 0.0f;
}
}
}
void DrawScrollSliderAsSphereAtUnifiedAxis(float sizeOfHandleCaps)
{
float distanceFromAnchorPos = 2.3f * sizeOfHandleCaps;
Vector3 unified45degAxis_forHandleSliders_normalized = theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.Get_unified45degAxis_forHandleSliders_normalized();
Vector3 restingPosition = theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.Position_worldspace + unified45degAxis_forHandleSliders_normalized * distanceFromAnchorPos;
float capSizeScaleFactor = sizeFactor_forBacksnappingSphereCaps;
GUIContent icon = handSymbol_forBothAxes;
float iconSizeFactor = sizeFactor_forMagnifierGlassIcons_onCylinders;
Vector2 iconPositionOffset_inScreenspace_relToHandleCapSize = new Vector2(-0.25f, 0.25f); //-> manually shifting the icon, so it appears centered over the handle cap.
EditorGUI.BeginChangeCheck();
InternalDXXL_ChartHandles.TwoDirectionalBacksnapSlider(ref travelledWorldSpaceDistanceAlongChartsXDirection_sinceMouseDown_for_unifiedDragHandle, ref travelledWorldSpaceDistanceAlongChartsYDirection_sinceMouseDown_for_unifiedDragHandle, restingPosition, theDrawXXLChartInspector_unserializedMonoB, capSizeScaleFactor, icon, iconSizeFactor, iconPositionOffset_inScreenspace_relToHandleCapSize);
bool hasChanged = EditorGUI.EndChangeCheck();
if (hasChanged)
{
theDrawXXLChartInspector_unserializedMonoB.alwaysEncapsulateAllValues = false;
theDrawXXLChartInspector_unserializedMonoB.scrollSinceMouseDown_fromUnifiedHandleSlider_asTravelledWorldSpaceDistanceAlongChartsXDirection = travelledWorldSpaceDistanceAlongChartsXDirection_sinceMouseDown_for_unifiedDragHandle;
theDrawXXLChartInspector_unserializedMonoB.scrollSinceMouseDown_fromUnifiedHandleSlider_asTravelledWorldSpaceDistanceAlongChartsYDirection = travelledWorldSpaceDistanceAlongChartsYDirection_sinceMouseDown_for_unifiedDragHandle;
}
else
{
if (GUIUtility.hotControl == 0)
{
travelledWorldSpaceDistanceAlongChartsXDirection_sinceMouseDown_for_unifiedDragHandle = 0.0f;
travelledWorldSpaceDistanceAlongChartsYDirection_sinceMouseDown_for_unifiedDragHandle = 0.0f;
theDrawXXLChartInspector_unserializedMonoB.scrollSinceMouseDown_fromUnifiedHandleSlider_asTravelledWorldSpaceDistanceAlongChartsXDirection = 0.0f;
theDrawXXLChartInspector_unserializedMonoB.scrollSinceMouseDown_fromUnifiedHandleSlider_asTravelledWorldSpaceDistanceAlongChartsYDirection = 0.0f;
}
}
}
void DrawZoomSliderAsCylinderAtXAxis(float sizeOfHandleCaps)
{
float distanceFromAnchorPos = distanceFromAnchorPosFactor_forBacksnappingCylinderCaps * sizeOfHandleCaps;
Vector3 sliderDirection_worldSpace_normalized = theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.xAxis.AxisVector_normalized_inWorldSpace;
Vector3 restingPosition = theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.Position_worldspace + theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.xAxis.AxisVector_inWorldSpace + sliderDirection_worldSpace_normalized * distanceFromAnchorPos;
Handles.CapFunction capFunction = Handles.CylinderHandleCap;
float capSizeScaleFactor = sizeFactor_forBacksnappingCylinderCaps;
GUIContent icon = magnifierGlassSymbol_atXAxis;
float iconSizeFactor = sizeFactor_forHandIcon_onConesAndSpheres;
Vector2 iconPositionOffset_inScreenspace_relToHandleCapSize = new Vector2(-0.22f, 0.2f); //-> manually shifting the icon, so it appears centered over the handle cap.
EditorGUI.BeginChangeCheck();
travelledWorldSpaceDistanceAlongSliderDirection_sinceMouseDown_for_zoomXAxisHandle = InternalDXXL_ChartHandles.OneDirectionalBacksnapSlider(travelledWorldSpaceDistanceAlongSliderDirection_sinceMouseDown_for_zoomXAxisHandle, restingPosition, theDrawXXLChartInspector_unserializedMonoB, sliderDirection_worldSpace_normalized, capFunction, capSizeScaleFactor, icon, iconSizeFactor, iconPositionOffset_inScreenspace_relToHandleCapSize, false, true);
bool hasChanged = EditorGUI.EndChangeCheck();
if (hasChanged)
{
theDrawXXLChartInspector_unserializedMonoB.alwaysEncapsulateAllValues = false;
float zoomWeight_m1_to_p1 = travelledWorldSpaceDistanceAlongSliderDirection_sinceMouseDown_for_zoomXAxisHandle / theDrawXXLChartInspector_unserializedMonoB.GetBacksnapSliderReferenceLength_inWorldspaceUnits();
theDrawXXLChartInspector_unserializedMonoB.xAxisZoomSinceMouseDown_fromHandleSlider_m1_to_p1 = zoomWeight_m1_to_p1;
}
else
{
if (GUIUtility.hotControl == 0)
{
travelledWorldSpaceDistanceAlongSliderDirection_sinceMouseDown_for_zoomXAxisHandle = 0.0f;
theDrawXXLChartInspector_unserializedMonoB.xAxisZoomSinceMouseDown_fromHandleSlider_m1_to_p1 = 0.0f;
}
}
}
void DrawZoomSliderAsCylinderAtYAxis(float sizeOfHandleCaps)
{
float distanceFromAnchorPos = distanceFromAnchorPosFactor_forBacksnappingCylinderCaps * sizeOfHandleCaps;
Vector3 sliderDirection_worldSpace_normalized = theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.yAxis.AxisVector_normalized_inWorldSpace;
Vector3 restingPosition = theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.Position_worldspace + theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.yAxis.AxisVector_inWorldSpace + sliderDirection_worldSpace_normalized * distanceFromAnchorPos;
Handles.CapFunction capFunction = Handles.CylinderHandleCap;
float capSizeScaleFactor = sizeFactor_forBacksnappingCylinderCaps;
GUIContent icon = magnifierGlassSymbol_atYAxis;
float iconSizeFactor = sizeFactor_forMagnifierGlassIcons_onCylinders;
Vector2 iconPositionOffset_inScreenspace_relToHandleCapSize = new Vector2(-0.23f, 0.24f); //-> manually shifting the icon, so it appears centered over the handle cap.
EditorGUI.BeginChangeCheck();
travelledWorldSpaceDistanceAlongSliderDirection_sinceMouseDown_for_zoomYAxisHandle = InternalDXXL_ChartHandles.OneDirectionalBacksnapSlider(travelledWorldSpaceDistanceAlongSliderDirection_sinceMouseDown_for_zoomYAxisHandle, restingPosition, theDrawXXLChartInspector_unserializedMonoB, sliderDirection_worldSpace_normalized, capFunction, capSizeScaleFactor, icon, iconSizeFactor, iconPositionOffset_inScreenspace_relToHandleCapSize, false, true);
bool hasChanged = EditorGUI.EndChangeCheck();
if (hasChanged)
{
theDrawXXLChartInspector_unserializedMonoB.alwaysEncapsulateAllValues = false;
float zoomWeight_m1_to_p1 = travelledWorldSpaceDistanceAlongSliderDirection_sinceMouseDown_for_zoomYAxisHandle / theDrawXXLChartInspector_unserializedMonoB.GetBacksnapSliderReferenceLength_inWorldspaceUnits();
theDrawXXLChartInspector_unserializedMonoB.yAxisZoomSinceMouseDown_fromHandleSlider_m1_to_p1 = zoomWeight_m1_to_p1;
}
else
{
if (GUIUtility.hotControl == 0)
{
travelledWorldSpaceDistanceAlongSliderDirection_sinceMouseDown_for_zoomYAxisHandle = 0.0f;
theDrawXXLChartInspector_unserializedMonoB.yAxisZoomSinceMouseDown_fromHandleSlider_m1_to_p1 = 0.0f;
}
}
}
void DrawZoomSliderAsCylinderAtUnifiedAxis(float sizeOfHandleCaps)
{
float distanceFromAnchorPos = 1.0f * sizeOfHandleCaps;
Vector3 sliderDirection_worldSpace_normalized = -theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.Get_unified45degAxis_forHandleSliders_normalized();
Vector3 restingPosition = theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.Position_worldspace - sliderDirection_worldSpace_normalized * distanceFromAnchorPos;
Handles.CapFunction capFunction = Handles.CylinderHandleCap;
float capSizeScaleFactor = sizeFactor_forBacksnappingCylinderCaps;
GUIContent icon = magnifierGlassSymbol_forBothAxes;
float iconSizeFactor = sizeFactor_forMagnifierGlassIcons_onCylinders;
Vector2 iconPositionOffset_inScreenspace_relToHandleCapSize = new Vector2(-0.25f, 0.25f); //-> manually shifting the icon, so it appears centered over the handle cap.
EditorGUI.BeginChangeCheck();
travelledWorldSpaceDistanceAlongSliderDirection_sinceMouseDown_for_forZoomBothAxesHandle = InternalDXXL_ChartHandles.OneDirectionalBacksnapSlider(travelledWorldSpaceDistanceAlongSliderDirection_sinceMouseDown_for_forZoomBothAxesHandle, restingPosition, theDrawXXLChartInspector_unserializedMonoB, sliderDirection_worldSpace_normalized, capFunction, capSizeScaleFactor, icon, iconSizeFactor, iconPositionOffset_inScreenspace_relToHandleCapSize, false, true);
bool hasChanged = EditorGUI.EndChangeCheck();
if (hasChanged)
{
theDrawXXLChartInspector_unserializedMonoB.alwaysEncapsulateAllValues = false;
float zoomWeight_m1_to_p1 = travelledWorldSpaceDistanceAlongSliderDirection_sinceMouseDown_for_forZoomBothAxesHandle / theDrawXXLChartInspector_unserializedMonoB.GetBacksnapSliderReferenceLength_inWorldspaceUnits();
theDrawXXLChartInspector_unserializedMonoB.bothAxesZoomSinceMouseDown_fromHandleSlider_m1_to_p1 = zoomWeight_m1_to_p1;
}
else
{
if (GUIUtility.hotControl == 0)
{
travelledWorldSpaceDistanceAlongSliderDirection_sinceMouseDown_for_forZoomBothAxesHandle = 0.0f;
theDrawXXLChartInspector_unserializedMonoB.bothAxesZoomSinceMouseDown_fromHandleSlider_m1_to_p1 = 0.0f;
}
}
}
void DrawCheckboxFor_showAllValues(float sizeOfHandleCaps)
{
float distanceFromAnchorPos = 3.6f * sizeOfHandleCaps;
Vector3 unified45degAxis_forHandleSliders_normalized = theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.Get_unified45degAxis_forHandleSliders_normalized();
Vector3 position = theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.Position_worldspace + unified45degAxis_forHandleSliders_normalized * distanceFromAnchorPos;
Vector2 checkmarkIconPositionOffset_inScreenspace_relToHandleCapSize = new Vector2(-0.25f, 0.25f); //-> manually shifting the icon, so it appears centered over the handle cap.
Vector2 crossIconPositionOffset_inScreenspace_relToHandleCapSize = new Vector2(-0.25f, 0.25f); //-> manually shifting the icon, so it appears centered over the handle cap.
bool checkmarkState_before = theDrawXXLChartInspector_unserializedMonoB.alwaysEncapsulateAllValues;
bool checkmarkState_after = InternalDXXL_ChartHandles.ShowAllButton(checkmarkState_before, position, theDrawXXLChartInspector_unserializedMonoB, sizeFactor_forBacksnappingSphereCaps, checkmarkSymbol, crossSymbol, sizeFactor_forCheckmarkIcon, sizeFactor_forCrossIcon, checkmarkIconPositionOffset_inScreenspace_relToHandleCapSize, crossIconPositionOffset_inScreenspace_relToHandleCapSize);
theDrawXXLChartInspector_unserializedMonoB.alwaysEncapsulateAllValues = checkmarkState_after;
}
public override void OnInspectorGUI()
{
if (theDrawXXLChartInspector_unserializedMonoB.CheckIfReferencedChartGotLost())
{
EditorGUILayout.HelpBox("The ChartDrawing that should be displayed with this component got lost for some reason, which normally leads to the automatic deletion of the whole gameobject." + Environment.NewLine + Environment.NewLine + "This gameobject has not been automatically deleted though, because it seems to host other components or has childs or parents attached." + Environment.NewLine + Environment.NewLine + "You can delete this component if you don't need it anymore. If you want to continue inspecting the chart then create a new chart inspector component via 'chartThatYouWantToInspect.CreateChartInspectionGameobject()'.", MessageType.Info, true);
}
else
{
int indentLevel_before = EditorGUI.indentLevel;
serializedObject.Update();
GUIStyle style_forFoldoutWithBoldText = new GUIStyle(EditorStyles.foldout);
style_forFoldoutWithBoldText.fontStyle = FontStyle.Bold;
DrawConsumedLines();
DrawHandles_andOptionallyZoomAndAxisScaling(style_forFoldoutWithBoldText);
DrawSection_sceneViewCamera(style_forFoldoutWithBoldText);
DrawSection_other(style_forFoldoutWithBoldText);
DrawSection_lines();
serializedObject.ApplyModifiedProperties();
EditorGUI.indentLevel = indentLevel_before;
}
}
void DrawConsumedLines()
{
SerializedProperty sP_drawnLinesPerPass = serializedObject.FindProperty("drawnSmallStraightLines_duringLastDrawRun");
GUIStyle style_ofConsumedLinesLabel = new GUIStyle();
style_ofConsumedLinesLabel.richText = true;
float allowedConsumedLines_0to1 = (float)sP_drawnLinesPerPass.intValue / (float)DrawBasics.MaxAllowedDrawnLinesPerFrame;
float hueValueOfColor = 0.33333f * (1.0f - allowedConsumedLines_0to1);
Color color_visualizingWarningForTooManyLines = SeededColorGenerator.GetColorFromHueAndLuminance_tunedTransitionsSpectrum(hueValueOfColor, 0.5f, 1.0f);
string coloredLineNumber = "<color=#" + ColorUtility.ToHtmlStringRGBA(color_visualizingWarningForTooManyLines) + ">" + sP_drawnLinesPerPass.intValue + "</color>";
string tooltipForBoth = "This chart is drawn with single small straight lines (like from 'Debug.DrawLine()'). If too many of these straight lines are drawn it may hit the Editor execution performance." + Environment.NewLine + Environment.NewLine + "The color becomes more red as the number reaches a critical area." + Environment.NewLine + Environment.NewLine + "(see also 'DrawXXL.DrawBasics.MaxAllowedDrawnLinesPerFrame')";
GUIContent drawnLinesWord = new GUIContent("Drawn small straight lines:", tooltipForBoth);
GUIContent drawnLinesNumber = new GUIContent(coloredLineNumber, tooltipForBoth);
EditorGUILayout.LabelField(drawnLinesWord, drawnLinesNumber, style_ofConsumedLinesLabel);
}
void DrawSection_sceneViewCamera(GUIStyle style_forFoldoutWithBoldText)
{
SerializedProperty serializedProperty_sceneViewCamSection_isExpanded = serializedObject.FindProperty("sceneViewCamSection_isExpanded");
serializedProperty_sceneViewCamSection_isExpanded.boolValue = EditorGUILayout.Foldout(serializedProperty_sceneViewCamSection_isExpanded.boolValue, "Scene view camera", true, style_forFoldoutWithBoldText);
if (serializedProperty_sceneViewCamSection_isExpanded.boolValue)
{
EditorGUI.indentLevel = EditorGUI.indentLevel + 1;
SerializedProperty serializedProperty_forceSceneViewCamToFollowChart = serializedObject.FindProperty("forceSceneViewCamToFollowChart");
GUILayout.BeginHorizontal();
GUILayout.Space(15.0f);
GUIContent guiContent_forbutton_setToChart = new GUIContent("Set to chart", "Set the Scene view camera position so that it looks at the chart.");
EditorGUI.BeginDisabledGroup(serializedProperty_forceSceneViewCamToFollowChart.boolValue);
if (GUILayout.Button(guiContent_forbutton_setToChart))
{
theDrawXXLChartInspector_unserializedMonoB.TrySetSceneViewCamToChart_dueToButtonClick();
}
EditorGUI.EndDisabledGroup();
GUILayout.EndHorizontal();
//The feature "Checkbox: Stay at chart" is disabled. Reason:
//-> The risk is too high, that a user activates "Scene View Camera - Stay at Chart"
//-> and then changes the GameObject
//-> and then looses track why his SceneView Camera is fixed and he cannot navigate anymore with his camera through the Scene.
GUILayout.Space(1.0f * EditorGUIUtility.singleLineHeight);
EditorGUI.indentLevel = EditorGUI.indentLevel - 1;
}
}
void DrawHandles_andOptionallyZoomAndAxisScaling(GUIStyle style_forFoldoutWithBoldText)
{
SerializedProperty sP_hideHandles_andInsteadUseInspectorSlidersForZoomAndScroll = serializedObject.FindProperty("hideHandles_andInsteadUseInspectorSlidersForZoomAndScroll");
sP_hideHandles_andInsteadUseInspectorSlidersForZoomAndScroll.boolValue = EditorGUILayout.ToggleLeft(new GUIContent("Hide handles and use inspector sliders instead", "This may be helpful if the handles cover important information." + Environment.NewLine + Environment.NewLine + "When hiding handles you can still zoom and scroll the chart via sliders here in the inspector."), sP_hideHandles_andInsteadUseInspectorSlidersForZoomAndScroll.boolValue);
if (sP_hideHandles_andInsteadUseInspectorSlidersForZoomAndScroll.boolValue)
{
EditorGUI.indentLevel = EditorGUI.indentLevel + 1;
DrawSection_cursor(style_forFoldoutWithBoldText);
DrawSection_axesScaling(style_forFoldoutWithBoldText);
EditorGUI.indentLevel = EditorGUI.indentLevel - 1;
}
}
void DrawSection_cursor(GUIStyle style_forFoldoutWithBoldText)
{
SerializedProperty serializedProperty_cursorSection_isExpanded = serializedObject.FindProperty("cursorSection_isExpanded");
serializedProperty_cursorSection_isExpanded.boolValue = EditorGUILayout.Foldout(serializedProperty_cursorSection_isExpanded.boolValue, "Cursor", true, style_forFoldoutWithBoldText);
if (serializedProperty_cursorSection_isExpanded.boolValue)
{
EditorGUI.indentLevel = EditorGUI.indentLevel + 1;
SerializedProperty serializedProperty_curr_cursorPosition_inChartspaceUnits = serializedObject.FindProperty("curr_cursorPosition_inChartspaceUnits");
EditorGUILayout.PropertyField(serializedProperty_curr_cursorPosition_inChartspaceUnits, new GUIContent("Position"));
GUILayout.Space(0.3f * EditorGUIUtility.singleLineHeight);
EditorGUILayout.PropertyField(serializedObject.FindProperty("cursorPos0to1_raw"), new GUIContent("Slide 0-1", "Move the cursor between the left end of the chart (0) and the right end of the chart (1)."));
EditorGUILayout.PropertyField(serializedObject.FindProperty("cursorPos0to1_finetune"), new GUIContent("Finetune", "Add fine offset to the cursor slide position."));
EditorGUILayout.PropertyField(serializedObject.FindProperty("cursorPos0to1_superFinetune"), new GUIContent("Super Finetune", "Add very fine offset to the cursor slide position."));
GUILayout.Space(1.0f * EditorGUIUtility.singleLineHeight);
EditorGUI.indentLevel = EditorGUI.indentLevel - 1;
}
}
void DrawSection_axesScaling(GUIStyle style_forFoldoutWithBoldText)
{
SerializedProperty sP_zoomForBothAxesToApply_fromInspectorSlider_m1_to_p1 = serializedObject.FindProperty("zoomForBothAxesToApply_fromInspectorSlider_m1_to_p1");
SerializedProperty sP_xAxisZoomToApply_fromInspectorSlider_m1_to_p1 = serializedObject.FindProperty("xAxisZoomToApply_fromInspectorSlider_m1_to_p1");
SerializedProperty sP_xAxisScrollToApply_fromInspectorSlider_m1_to_p1 = serializedObject.FindProperty("xAxisScrollToApply_fromInspectorSlider_m1_to_p1");
SerializedProperty sP_yAxisZoomToApply_fromInspectorSlider_m1_to_p1 = serializedObject.FindProperty("yAxisZoomToApply_fromInspectorSlider_m1_to_p1");
SerializedProperty sP_yAxisScrollToApply_fromInspectorSlider_m1_to_p1 = serializedObject.FindProperty("yAxisScrollToApply_fromInspectorSlider_m1_to_p1");
SerializedProperty serializedProperty_axesSection_isExpanded = serializedObject.FindProperty("axesSection_isExpanded");
serializedProperty_axesSection_isExpanded.boolValue = EditorGUILayout.Foldout(serializedProperty_axesSection_isExpanded.boolValue, "Axes Scaling", true, style_forFoldoutWithBoldText);
if (serializedProperty_axesSection_isExpanded.boolValue)
{
EditorGUI.indentLevel = EditorGUI.indentLevel + 1;
GUILayout.Space(0.3f * EditorGUIUtility.singleLineHeight);
GUILayout.BeginHorizontal();
GUILayout.Space(15.0f);
GUIContent guiContent_forbutton_showEverything = new GUIContent("Show everything", "Set the axis scaling so that all datapoints of all non-hidden lines are visible.");
if (GUILayout.Button(guiContent_forbutton_showEverything, GUILayout.Width(150)))
{
theDrawXXLChartInspector_unserializedMonoB.ResetAxesScalingTo_encapsulateAllValues();
}
SerializedProperty serializedProperty_alwaysEncapsulateAllValues = serializedObject.FindProperty("alwaysEncapsulateAllValues");
GUIContent guiContent_alwaysEncapsulateAllValues = new GUIContent("Always", "This continuously overwrites the axis scaling so that always all datapoints are visible.");
serializedProperty_alwaysEncapsulateAllValues.boolValue = GUILayout.Toggle(serializedProperty_alwaysEncapsulateAllValues.boolValue, guiContent_alwaysEncapsulateAllValues);
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Space(15.0f);
GUIContent guiContent_forbutton_revertChanges = new GUIContent("Revert changes", "Set the axis scaling to as it was in the moment where the chart was frozen for inspection.");
if (GUILayout.Button(guiContent_forbutton_revertChanges, GUILayout.Width(150)))
{
theDrawXXLChartInspector_unserializedMonoB.ResetAxesScalingTo_stateInMomentOfComponentCreation();
}
GUILayout.EndHorizontal();
EditorGUI.BeginDisabledGroup(serializedProperty_alwaysEncapsulateAllValues.boolValue);
GUILayout.Space(0.3f * EditorGUIUtility.singleLineHeight);
EditorGUILayout.PropertyField(sP_zoomForBothAxesToApply_fromInspectorSlider_m1_to_p1, new GUIContent("Zoom"));
GUILayout.Space(0.7f * EditorGUIUtility.singleLineHeight);
EditorGUILayout.PropertyField(sP_xAxisZoomToApply_fromInspectorSlider_m1_to_p1, new GUIContent("Zoom X"));
EditorGUILayout.PropertyField(sP_xAxisScrollToApply_fromInspectorSlider_m1_to_p1, new GUIContent("Scroll X"));
GUILayout.Space(0.7f * EditorGUIUtility.singleLineHeight);
EditorGUILayout.PropertyField(sP_yAxisZoomToApply_fromInspectorSlider_m1_to_p1, new GUIContent("Zoom Y"));
EditorGUILayout.PropertyField(sP_yAxisScrollToApply_fromInspectorSlider_m1_to_p1, new GUIContent("Scroll Y"));
GUILayout.Space(1.0f * EditorGUIUtility.singleLineHeight);
EditorGUI.EndDisabledGroup();
EditorGUI.indentLevel = EditorGUI.indentLevel - 1;
}
if (EditorGUIUtility.hotControl == 0)
{
//This resets the sliders to their zero position in the middle if they are not clicked or dragged
//-> It fakes an "Event.MouseUp" event
sP_zoomForBothAxesToApply_fromInspectorSlider_m1_to_p1.floatValue = 0.0f;
sP_xAxisZoomToApply_fromInspectorSlider_m1_to_p1.floatValue = 0.0f;
sP_xAxisScrollToApply_fromInspectorSlider_m1_to_p1.floatValue = 0.0f;
sP_yAxisZoomToApply_fromInspectorSlider_m1_to_p1.floatValue = 0.0f;
sP_yAxisScrollToApply_fromInspectorSlider_m1_to_p1.floatValue = 0.0f;
}
}
void DrawSection_other(GUIStyle style_forFoldoutWithBoldText)
{
SerializedProperty serializedProperty_otherSection_isExpanded = serializedObject.FindProperty("otherSection_isExpanded");
serializedProperty_otherSection_isExpanded.boolValue = EditorGUILayout.Foldout(serializedProperty_otherSection_isExpanded.boolValue, "Other", true, style_forFoldoutWithBoldText);
if (serializedProperty_otherSection_isExpanded.boolValue)
{
EditorGUI.indentLevel = EditorGUI.indentLevel + 1;
DrawSection_csvExport();
DrawSection_clearLineValues();
EditorGUILayout.PropertyField(serializedObject.FindProperty("sizeOfDatapointVisualization"), new GUIContent("Size (cursor values)"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("curr_luminanceOfLineColors_accordingToSlider"), new GUIContent("Luminance (line colors)", "Changing this can improve the readability of the lines in front of different background brightness."));
EditorGUILayout.PropertyField(serializedObject.FindProperty("lineNamePositions"), new GUIContent("Line names position"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("lineNames_sizeScaleFactor"), new GUIContent("Size (line names)"));
int new_maxDisplayedPointOfInterestTextBoxesPerSide = EditorGUILayout.IntField(new GUIContent("Maximum number of Text Boxes (for Points of Interest)", "Some Points of Interest display a text box with explantion text in the top corners of the chart. In some unforeseen situation, for example if many invalid float values are added as data points, the number of text boxes that notify you of these invalid float values can rapidly grow and as a result slow down the Editor performance."), theDrawXXLChartInspector_unserializedMonoB.Get_maxDisplayedPointOfInterestTextBoxesPerSide());
if (new_maxDisplayedPointOfInterestTextBoxesPerSide != theDrawXXLChartInspector_unserializedMonoB.Get_maxDisplayedPointOfInterestTextBoxesPerSide())
{
theDrawXXLChartInspector_unserializedMonoB.Set_maxDisplayedPointOfInterestTextBoxesPerSide(new_maxDisplayedPointOfInterestTextBoxesPerSide);
}
GUILayout.Space(1.0f * EditorGUIUtility.singleLineHeight);
EditorGUI.indentLevel = EditorGUI.indentLevel - 1;
}
else
{
GUILayout.Space(0.5f * EditorGUIUtility.singleLineHeight);
}
}
void DrawSection_csvExport()
{
SerializedProperty serializedProperty_csvExportSection_isExpanded = serializedObject.FindProperty("csvExportSection_isExpanded");
serializedProperty_csvExportSection_isExpanded.boolValue = EditorGUILayout.Foldout(serializedProperty_csvExportSection_isExpanded.boolValue, "CSV file export", true);
if (serializedProperty_csvExportSection_isExpanded.boolValue)
{
EditorGUI.indentLevel = EditorGUI.indentLevel + 1;
EditorGUILayout.HelpBox("The file is written into the Assets folder of your project. Existing files with the same name will not be overwritten but a sequential number will be added to the new file name.", MessageType.None, true);
SerializedProperty serializedProperty_csvFileName = serializedObject.FindProperty("csvFileName");
serializedProperty_csvFileName.stringValue = EditorGUILayout.TextField("File name", serializedProperty_csvFileName.stringValue);
GUILayout.BeginHorizontal();
GUILayout.Space(30.0f);
if (GUILayout.Button("Export"))
{
theDrawXXLChartInspector_unserializedMonoB.ExportCSVFile(serializedProperty_csvFileName.stringValue);
}
GUILayout.EndHorizontal();
GUILayout.Space(1.0f * EditorGUIUtility.singleLineHeight);
EditorGUI.indentLevel = EditorGUI.indentLevel - 1;
}
}
void DrawSection_clearLineValues()
{
SerializedProperty serializedProperty_clearButtonSection_isExpanded = serializedObject.FindProperty("clearButtonSection_isExpanded");
serializedProperty_clearButtonSection_isExpanded.boolValue = EditorGUILayout.Foldout(serializedProperty_clearButtonSection_isExpanded.boolValue, "Clear Line Data", true);
if (serializedProperty_clearButtonSection_isExpanded.boolValue)
{
EditorGUI.indentLevel = EditorGUI.indentLevel + 1;
EditorGUILayout.HelpBox("No 'Undo' possible.", MessageType.Warning, true);
GUILayout.BeginHorizontal();
GUILayout.Space(30.0f);
if (GUILayout.Button(new GUIContent("Clear all Line Data Values", "This deletes all data points of all lines of this chart, so you can start with a fresh unfilled chart." + Environment.NewLine + Environment.NewLine + "Be cautious, because this cannot be undone.")))
{
theDrawXXLChartInspector_unserializedMonoB.ClearLineData();
}
GUILayout.EndHorizontal();
GUILayout.Space(1.0f * EditorGUIUtility.singleLineHeight);
EditorGUI.indentLevel = EditorGUI.indentLevel - 1;
}
}
void DrawSection_lines()
{
GUIStyle boldFontStyle = new GUIStyle();
boldFontStyle.fontStyle = FontStyle.Bold;
GUILayout.Label("Lines:", boldFontStyle);
SerializedProperty serializedProperty_specsForInspectorForEachDrawnLine = serializedObject.FindProperty("specsForInspector_forEachDrawnLine");
for (int i = 0; i < serializedProperty_specsForInspectorForEachDrawnLine.arraySize; i++)
{
EditorGUILayout.PropertyField(serializedProperty_specsForInspectorForEachDrawnLine.GetArrayElementAtIndex(i));
}
}
}
#endif
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5688d1000cb135347840e17b11efe57b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,196 @@
namespace DrawXXL
{
using System;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
[CustomPropertyDrawer(typeof(InternalDXXL_LineSpecsForChartInspector))]
public class LineSpecsForInspectorDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
float currYOffset = 0.0f;
SerializedProperty serializedProperty_currentHideLineState = property.FindPropertyRelative("currentHideLineState");
Rect space_ofMainLineHideCheckboxToggle = new Rect(position.x + 0.4f * EditorGUIUtility.singleLineHeight, position.y + currYOffset, position.width, EditorGUIUtility.singleLineHeight);
serializedProperty_currentHideLineState.boolValue = !EditorGUI.Toggle(space_ofMainLineHideCheckboxToggle, !serializedProperty_currentHideLineState.boolValue);
SerializedProperty serializedProperty_lineSection_isExpanded = property.FindPropertyRelative("lineSection_isExpanded");
Rect space_ofMainFoldout = new Rect(position.x, position.y + currYOffset, position.width, EditorGUIUtility.singleLineHeight);
serializedProperty_lineSection_isExpanded.boolValue = EditorGUI.Foldout(space_ofMainFoldout, serializedProperty_lineSection_isExpanded.boolValue, GUIContent.none, true, EditorStyles.foldout);
SerializedProperty serializedProperty_lineColor = property.FindPropertyRelative("lineColor");
SerializedProperty serializedProperty_linesCompoundName = property.FindPropertyRelative("linesCompoundName");
GUIStyle richtextEnabled_fontStyle = new GUIStyle();
richtextEnabled_fontStyle.richText = true;
float indent_ofColoredLineName = 50;
Rect space_ofColoredLineName = new Rect(position.x + 1.6f * EditorGUIUtility.singleLineHeight, position.y + currYOffset, position.width - indent_ofColoredLineName, position.height);
EditorGUI.LabelField(space_ofColoredLineName, "Line: <b><color=#" + ColorUtility.ToHtmlStringRGBA(serializedProperty_lineColor.colorValue) + ">" + serializedProperty_linesCompoundName.stringValue + "</color></b>", richtextEnabled_fontStyle);
if (serializedProperty_lineSection_isExpanded.boolValue)
{
int previousIndent = EditorGUI.indentLevel;
EditorGUI.indentLevel = EditorGUI.indentLevel + 1;
currYOffset = currYOffset + (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing);
Rect space_ofColorPicker = new Rect(position.x, position.y + currYOffset, position.width, EditorGUIUtility.singleLineHeight);
EditorGUI.PropertyField(space_ofColorPicker, serializedProperty_lineColor, new GUIContent("Color"));
currYOffset = currYOffset + (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing);
SerializedProperty serializedProperty_currentHideCursorXState_duringComponentInspectionPhase = property.FindPropertyRelative("currentHideCursorXState_duringComponentInspectionPhase");
Rect space_ofHideCursorXToggle = new Rect(position.x, position.y + currYOffset, position.width, EditorGUIUtility.singleLineHeight);
serializedProperty_currentHideCursorXState_duringComponentInspectionPhase.boolValue = !EditorGUI.Toggle(space_ofHideCursorXToggle, "Draw X value", !serializedProperty_currentHideCursorXState_duringComponentInspectionPhase.boolValue);
currYOffset = currYOffset + (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing);
SerializedProperty serializedProperty_currentHideCursorYState_duringComponentInspectionPhase = property.FindPropertyRelative("currentHideCursorYState_duringComponentInspectionPhase");
Rect space_ofHideCursorYToggle = new Rect(position.x, position.y + currYOffset, position.width, EditorGUIUtility.singleLineHeight);
serializedProperty_currentHideCursorYState_duringComponentInspectionPhase.boolValue = !EditorGUI.Toggle(space_ofHideCursorYToggle, "Draw Y value", !serializedProperty_currentHideCursorYState_duringComponentInspectionPhase.boolValue);
DrawXXLChartInspector theDrawXXLChartInspector = (DrawXXLChartInspector)property.serializedObject.targetObject;
bool thisLineIsTheOnlyOneOfTheChart = theDrawXXLChartInspector.ContainsOnly1Line_hiddenOrUnhidden();
currYOffset = currYOffset + (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing);
EditorGUI.BeginDisabledGroup(thisLineIsTheOnlyOneOfTheChart);
SerializedProperty serializedProperty_i_ofThisLineSpec_insideChartInspectorsLinesSpecsArray = property.FindPropertyRelative("i_ofThisLineSpec_insideChartInspectorsLinesSpecsArray");
Rect space_ofButton_hideAllOtherLines = new Rect(position.x + 15.0f, position.y + currYOffset, 150.0f, EditorGUIUtility.singleLineHeight);
if (theDrawXXLChartInspector.AllOtherLinesAreHidden(serializedProperty_i_ofThisLineSpec_insideChartInspectorsLinesSpecsArray.intValue))
{
if (GUI.Button(space_ofButton_hideAllOtherLines, "Unhide all lines "))
{
theDrawXXLChartInspector.UnhideAllLines();
}
}
else
{
if (GUI.Button(space_ofButton_hideAllOtherLines, "Hide all other lines "))
{
theDrawXXLChartInspector.HideAllOtherLines(serializedProperty_i_ofThisLineSpec_insideChartInspectorsLinesSpecsArray.intValue);
}
}
currYOffset = currYOffset + (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing);
Rect space_ofButton_hideAllOtherCursors = new Rect(position.x + 15.0f, position.y + currYOffset, 150.0f, EditorGUIUtility.singleLineHeight);
if (theDrawXXLChartInspector.AllOtherCursorsAreHidden(serializedProperty_i_ofThisLineSpec_insideChartInspectorsLinesSpecsArray.intValue))
{
if (GUI.Button(space_ofButton_hideAllOtherCursors, "Unhide all cursors"))
{
theDrawXXLChartInspector.UnhideAllCursors(serializedProperty_i_ofThisLineSpec_insideChartInspectorsLinesSpecsArray.intValue);
}
}
else
{
if (GUI.Button(space_ofButton_hideAllOtherCursors, "Hide all other cursors"))
{
theDrawXXLChartInspector.HideAllOtherCursors(serializedProperty_i_ofThisLineSpec_insideChartInspectorsLinesSpecsArray.intValue);
}
}
EditorGUI.EndDisabledGroup();
currYOffset = currYOffset + (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing);
SerializedProperty serializedProperty_alpha_ofVertFillLines = property.FindPropertyRelative("alpha_ofVertFillLines");
GUIContent guiContent_for_alpha_ofVertFillLines = new GUIContent("Fill area (alpha)");
Rect space_of_alpha_ofVertFillLines = new Rect(position.x, position.y + currYOffset, position.width, EditorGUIUtility.singleLineHeight);
EditorGUI.PropertyField(space_of_alpha_ofVertFillLines, serializedProperty_alpha_ofVertFillLines, guiContent_for_alpha_ofVertFillLines);
if (serializedProperty_alpha_ofVertFillLines.floatValue < 0.001f) { serializedProperty_alpha_ofVertFillLines.floatValue = 0.0f; } //-> prenting float calculation uncertainty errors to accidentaly activate the many drawn lines for fillVerticalSpace
currYOffset = currYOffset + (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing);
SerializedProperty serializedProperty_lineWidth = property.FindPropertyRelative("lineWidth");
GUIContent guiContent_forWidthSlider = new GUIContent("Width", "This is relative to the chart height." + Environment.NewLine + Environment.NewLine + "Performance warning: Setting this to values other than 0 can significantly increase the number of drawn lines.");
Rect space_ofWidthSlider = new Rect(position.x, position.y + currYOffset, position.width, EditorGUIUtility.singleLineHeight);
EditorGUI.PropertyField(space_ofWidthSlider, serializedProperty_lineWidth, guiContent_forWidthSlider);
if (serializedProperty_lineWidth.floatValue < 0.00005f) { serializedProperty_lineWidth.floatValue = 0.0f; } //-> prenting float calculation uncertainty errors to accidentaly activate the many drawn lines for non-zeroWidth-lines
currYOffset = currYOffset + (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing);
Rect space_of_connectionsType = new Rect(position.x, position.y + currYOffset, position.width, EditorGUIUtility.singleLineHeight);
EditorGUI.PropertyField(space_of_connectionsType, property.FindPropertyRelative("connectionsType"), new GUIContent("Connection style"));
currYOffset = currYOffset + (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing);
Rect space_of_dataPointVisualization = new Rect(position.x, position.y + currYOffset, position.width, EditorGUIUtility.singleLineHeight);
EditorGUI.PropertyField(space_of_dataPointVisualization, property.FindPropertyRelative("dataPointVisualization"), new GUIContent("Points style"));
bool datapointVisualizerOfLineAreInvisible = theDrawXXLChartInspector.DatapointVisualizerOfLineAreInvisible(serializedProperty_i_ofThisLineSpec_insideChartInspectorsLinesSpecsArray.intValue);
EditorGUI.BeginDisabledGroup(datapointVisualizerOfLineAreInvisible);
currYOffset = currYOffset + (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing);
Rect space_of_dataPointVisualization_size = new Rect(position.x, position.y + currYOffset, position.width, EditorGUIUtility.singleLineHeight);
EditorGUI.PropertyField(space_of_dataPointVisualization_size, property.FindPropertyRelative("dataPointVisualization_size"), new GUIContent("Points size"));
EditorGUI.EndDisabledGroup();
currYOffset = currYOffset + (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing);
GUIStyle style_forDatapointValuesHeadline = new GUIStyle(EditorStyles.foldout);
style_forDatapointValuesHeadline.richText = true;
SerializedProperty serializedProperty_datapointValuesSection_isExpanded = property.FindPropertyRelative("datapointValuesSection_isExpanded");
Rect space_ofDatapointArrayFoldout = new Rect(position.x, position.y + currYOffset, position.width, EditorGUIUtility.singleLineHeight);
serializedProperty_datapointValuesSection_isExpanded.boolValue = EditorGUI.Foldout(space_ofDatapointArrayFoldout, serializedProperty_datapointValuesSection_isExpanded.boolValue, "<color=#" + ColorUtility.ToHtmlStringRGBA(serializedProperty_lineColor.colorValue) + ">Datapoint Values</color> (read only)", true, style_forDatapointValuesHeadline);
if (serializedProperty_datapointValuesSection_isExpanded.boolValue)
{
EditorGUI.indentLevel = EditorGUI.indentLevel + 1;
SerializedProperty arrayOfNeighboringDatapoints = property.FindPropertyRelative("neighboringDatapointValues");
int arraySize = arrayOfNeighboringDatapoints.arraySize;
currYOffset = currYOffset + 1.5f * EditorGUIUtility.singleLineHeight;
Rect space_ofArrayLengthChooser = new Rect(position.x, position.y + currYOffset, position.width, EditorGUIUtility.singleLineHeight);
EditorGUI.PropertyField(space_ofArrayLengthChooser, property.FindPropertyRelative("numberOfDisplayedDatapointsInArray"), new GUIContent("Listed values"));
currYOffset = currYOffset + 1.5f * EditorGUIUtility.singleLineHeight;
int i_insideShortenedForInspectorArray_markingTheValueAtCursor = property.FindPropertyRelative("i_insideShortenedForInspectorArray_markingTheValueAtCursor").intValue;
for (int i = 0; i < arraySize; i++)
{
SerializedProperty datapointValuesOfCurrentSlot = arrayOfNeighboringDatapoints.GetArrayElementAtIndex(i);
string slotName = GetArraySlotName(i, i_insideShortenedForInspectorArray_markingTheValueAtCursor);
Rect space_ofCurrDataPoint = new Rect(position.x, position.y + (currYOffset + (i * (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing))), position.width, EditorGUIUtility.singleLineHeight);
EditorGUI.PropertyField(space_ofCurrDataPoint, datapointValuesOfCurrentSlot, new GUIContent(slotName));
}
}
EditorGUI.indentLevel = previousIndent;
}
}
string GetArraySlotName(int i, int i_insideShortenedForInspectorArray_markingTheValueAtCursor)
{
int indexesDistance_toCursor = i - i_insideShortenedForInspectorArray_markingTheValueAtCursor;
if (indexesDistance_toCursor == 0)
{
return ("<b>At Cursor</b>");
}
else
{
if (indexesDistance_toCursor < 0)
{
return ("Cursor -" + Mathf.Abs(indexesDistance_toCursor));
}
else
{
return ("Cursor +" + Mathf.Abs(indexesDistance_toCursor));
}
}
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
if (property.FindPropertyRelative("lineSection_isExpanded").boolValue)
{
if (property.FindPropertyRelative("datapointValuesSection_isExpanded").boolValue)
{
int displayedDatapointValues = property.FindPropertyRelative("neighboringDatapointValues").arraySize;
return (EditorGUIUtility.singleLineHeight) * (15.0f + displayedDatapointValues) + (EditorGUIUtility.standardVerticalSpacing) * (13.0f + displayedDatapointValues);
}
else
{
return (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing) * 13.0f;
}
}
else
{
return EditorGUIUtility.singleLineHeight;
}
}
}
#endif
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9784fcad8f2d38947a80c2a6124dd623
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,47 @@
namespace DrawXXL
{
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
[CustomPropertyDrawer(typeof(InternalDXXL_NeighboringDatapointForChartInspector))]
public class NeighboringDatapointForInspectorDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
GUIStyle labelStyle = new GUIStyle(EditorStyles.label);
labelStyle.richText = true;
EditorGUI.LabelField(position, label, labelStyle);
float previousLabelWidth = EditorGUIUtility.labelWidth;
float xStartPos = position.x + 0.25f * position.width;
float width_allThree = position.width - xStartPos + EditorGUIUtility.singleLineHeight;
float xWidth = width_allThree * 0.28f;
EditorGUIUtility.labelWidth = 40.0f;
Rect space_ofX = new Rect(xStartPos, position.y, xWidth + 1.3f * EditorGUIUtility.singleLineHeight, position.height);
EditorGUI.PropertyField(space_ofX, property.FindPropertyRelative("x"), new GUIContent("X"));
float yStartPos = xStartPos + xWidth;
float yWidth = width_allThree * 0.28f;
EditorGUIUtility.labelWidth = 40.0f;
Rect space_ofY = new Rect(yStartPos, position.y, yWidth + 1.3f * EditorGUIUtility.singleLineHeight, position.height);
EditorGUI.PropertyField(space_ofY, property.FindPropertyRelative("y"), new GUIContent("Y"));
float dStartPos = yStartPos + yWidth;
float dWidth = width_allThree * 0.44f;
EditorGUIUtility.labelWidth = 72.0f;
Rect space_ofDelta = new Rect(dStartPos, position.y, dWidth, position.height);
EditorGUI.PropertyField(space_ofDelta, property.FindPropertyRelative("deltaSincePrecedingY"), new GUIContent("delta Y"));
EditorGUIUtility.labelWidth = previousLabelWidth;
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return EditorGUIUtility.singleLineHeight;
}
}
#endif
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 14f2c736c6c47e84796c3b4ed6761626
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ba836645a0c573c4e8f0411c1cc6afad
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7248b4bbde31bdc48bc0544ecf731e81
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,437 @@
namespace DrawXXL
{
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
using DrawXXL;
public class InternalDXXL_ChartHandles
{
static float valueToSlide_duringMouseDown;
static Vector2 currentMousePosition;
static Vector2 mousePosition_duringMouseDown;
static Vector3 sliderPosition_worldSpace_duringMouseDown;
public static float CursorSlider(bool isAtLowerEndOfCursorsVertLine_notAtUpperEnd, float valueToSlide, DrawXXLChartInspector theDrawXXLChartInspector_unserializedMonoB)
{
int control_ID = GUIUtility.GetControlID(FocusType.Passive);
Event currentEvent = Event.current;
Vector3 current_sliderPosition_worldSpace = Get_current_cursorSliderPosition_worldSpace(isAtLowerEndOfCursorsVertLine_notAtUpperEnd, theDrawXXLChartInspector_unserializedMonoB);
switch (currentEvent.GetTypeForControl(control_ID))
{
case EventType.MouseDown:
if ((HandleUtility.nearestControl == control_ID) && (currentEvent.button == 0) && (currentEvent.alt == false))
{
GUIUtility.hotControl = control_ID;
valueToSlide_duringMouseDown = valueToSlide;
mousePosition_duringMouseDown = currentEvent.mousePosition;
currentMousePosition = currentEvent.mousePosition;
sliderPosition_worldSpace_duringMouseDown = current_sliderPosition_worldSpace;
currentEvent.Use();
EditorGUIUtility.SetWantsMouseJumping(1);
}
break;
case EventType.MouseUp:
if (GUIUtility.hotControl == control_ID)
{
GUIUtility.hotControl = 0;
currentEvent.Use();
EditorGUIUtility.SetWantsMouseJumping(0);
}
break;
case EventType.MouseDrag:
if (GUIUtility.hotControl == control_ID)
{
currentMousePosition = currentMousePosition + currentEvent.delta;
Vector3 cursorSlideDirection = theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.xAxis.AxisVector_normalized_inWorldSpace;
float travelledDistance_sinceMouseDown = HandleUtility.CalcLineTranslation(mousePosition_duringMouseDown, currentMousePosition, sliderPosition_worldSpace_duringMouseDown, cursorSlideDirection);
valueToSlide = valueToSlide_duringMouseDown + travelledDistance_sinceMouseDown;
GUI.changed = true;
currentEvent.Use();
}
break;
case EventType.Repaint:
Color color_before = Handles.color;
TrySetColorDuringMouseInteraction(control_ID, theDrawXXLChartInspector_unserializedMonoB, currentEvent);
DrawConeCap(isAtLowerEndOfCursorsVertLine_notAtUpperEnd, control_ID, theDrawXXLChartInspector_unserializedMonoB, EventType.Repaint);
Handles.color = color_before;
break;
case EventType.Layout:
DrawConeCap(isAtLowerEndOfCursorsVertLine_notAtUpperEnd, control_ID, theDrawXXLChartInspector_unserializedMonoB, EventType.Layout);
break;
default:
break;
}
return valueToSlide;
}
static Vector3 Get_current_cursorSliderPosition_worldSpace(bool isAtLowerEndOfCursorsVertLine_notAtUpperEnd, DrawXXLChartInspector theDrawXXLChartInspector_unserializedMonoB)
{
return (isAtLowerEndOfCursorsVertLine_notAtUpperEnd ? theDrawXXLChartInspector_unserializedMonoB.GetCursorPosOnLowerEndOfChart() : theDrawXXLChartInspector_unserializedMonoB.GetCursorPosOnHigherEndOfChart());
}
static void DrawConeCap(bool isAtLowerEndOfCursorsVertLine_notAtUpperEnd, int control_ID, DrawXXLChartInspector theDrawXXLChartInspector_unserializedMonoB, EventType eventType)
{
Matrix4x4 matrix_before = Handles.matrix;
float sizeOfCursorHandleCone = theDrawXXLChartInspector_unserializedMonoB.GetHeightOfCursorPyramid();
Vector3 position_ofCustomMatrixSpace = Get_current_cursorSliderPosition_worldSpace(isAtLowerEndOfCursorsVertLine_notAtUpperEnd, theDrawXXLChartInspector_unserializedMonoB);
Vector3 positionOfCone_insideCustomMatrixSpace = Vector3.forward * (0.5f * sizeOfCursorHandleCone);//-> shifting the cone, so that his base it at the "position_ofCustomMatrixSpace", and not his center
Vector3 forwardOfCustomMatrixSpace = isAtLowerEndOfCursorsVertLine_notAtUpperEnd ? (theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.yAxis.AxisVector_normalized_inWorldSpace) : (-theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.yAxis.AxisVector_normalized_inWorldSpace);
Quaternion rotation_ofCustomMatrixSpace = Quaternion.LookRotation(forwardOfCustomMatrixSpace);
Quaternion rotationOfCone_insideCustomMatrixSpace = Quaternion.identity; //-> no rotation inside the custom matrix space. The cone rotation is already done by rotation the whole custom matrix space.
float coneBase_scaleFactor = 3.0f;
Vector3 scale_ofCustomMatrixSpace = new Vector3(coneBase_scaleFactor, coneBase_scaleFactor, 1.0f); //-> This is the reason for the whole custom matrix: Warping the cone shape, so that appears less pointy
Matrix4x4 warpedMatrix_oriniatingAtConeBase = Matrix4x4.TRS(position_ofCustomMatrixSpace, rotation_ofCustomMatrixSpace, scale_ofCustomMatrixSpace);
Handles.matrix = warpedMatrix_oriniatingAtConeBase;
Handles.ConeHandleCap(control_ID, positionOfCone_insideCustomMatrixSpace, rotationOfCone_insideCustomMatrixSpace, sizeOfCursorHandleCone, eventType);
Handles.matrix = matrix_before;
}
public static float OneDirectionalBacksnapSlider(float travelledWorldSpaceDistanceAlongDirection_sinceMouseDown, Vector3 restingPosition, DrawXXLChartInspector theDrawXXLChartInspector_unserializedMonoB, Vector3 sliderDirection_worldSpace_normalized, Handles.CapFunction capFunction, float capSizeScaleFactor, GUIContent icon, float iconSizeFactor, Vector2 iconPositionOffset_inScreenspace_relToHandleCapSize, bool clampTravelledDistance_inThePositiveDirection, bool drawSpiralSpring)
{
//-> see "HandlesExamples.AnalogJoystickSlider()" for a more generic version of this function
int control_ID = GUIUtility.GetControlID(FocusType.Passive);
Event currentEvent = Event.current;
switch (currentEvent.GetTypeForControl(control_ID))
{
case EventType.MouseDown:
if ((HandleUtility.nearestControl == control_ID) && (currentEvent.button == 0) && (currentEvent.alt == false))
{
GUIUtility.hotControl = control_ID;
mousePosition_duringMouseDown = currentEvent.mousePosition;
currentMousePosition = currentEvent.mousePosition;
theDrawXXLChartInspector_unserializedMonoB.SaveZoomAndScrollState_onMouseDown();
currentEvent.Use();
EditorGUIUtility.SetWantsMouseJumping(1);
}
break;
case EventType.MouseUp:
if (GUIUtility.hotControl == control_ID)
{
travelledWorldSpaceDistanceAlongDirection_sinceMouseDown = 0.0f;
GUIUtility.hotControl = 0;
currentEvent.Use();
EditorGUIUtility.SetWantsMouseJumping(0);
}
break;
case EventType.MouseDrag:
if (GUIUtility.hotControl == control_ID)
{
currentMousePosition = currentMousePosition + currentEvent.delta;
travelledWorldSpaceDistanceAlongDirection_sinceMouseDown = HandleUtility.CalcLineTranslation(mousePosition_duringMouseDown, currentMousePosition, restingPosition, sliderDirection_worldSpace_normalized);
travelledWorldSpaceDistanceAlongDirection_sinceMouseDown = TryClampTravelledDistanceInThePositiveDirection(clampTravelledDistance_inThePositiveDirection, travelledWorldSpaceDistanceAlongDirection_sinceMouseDown, theDrawXXLChartInspector_unserializedMonoB);
GUI.changed = true;
currentEvent.Use();
}
break;
case EventType.Repaint:
Color color_before = Handles.color;
TrySetColorDuringMouseInteraction(control_ID, theDrawXXLChartInspector_unserializedMonoB, currentEvent);
TryDrawSpiralSpring(control_ID, drawSpiralSpring, travelledWorldSpaceDistanceAlongDirection_sinceMouseDown, restingPosition, theDrawXXLChartInspector_unserializedMonoB, sliderDirection_worldSpace_normalized);
DrawOneDimensionalBacksnapSliderCap(control_ID, travelledWorldSpaceDistanceAlongDirection_sinceMouseDown, restingPosition, theDrawXXLChartInspector_unserializedMonoB, sliderDirection_worldSpace_normalized, capFunction, capSizeScaleFactor, EventType.Repaint);
Handles.color = color_before;
break;
case EventType.Layout:
DrawOneDimensionalBacksnapSliderCap(control_ID, travelledWorldSpaceDistanceAlongDirection_sinceMouseDown, restingPosition, theDrawXXLChartInspector_unserializedMonoB, sliderDirection_worldSpace_normalized, capFunction, capSizeScaleFactor, EventType.Layout);
break;
default:
break;
}
DrawIcon_onOneDimensionalBacksnapSlider(travelledWorldSpaceDistanceAlongDirection_sinceMouseDown, restingPosition, theDrawXXLChartInspector_unserializedMonoB, sliderDirection_worldSpace_normalized, icon, iconSizeFactor, iconPositionOffset_inScreenspace_relToHandleCapSize);
return travelledWorldSpaceDistanceAlongDirection_sinceMouseDown;
}
static float TryClampTravelledDistanceInThePositiveDirection(bool clampTravelledDistance_inThePositiveDirection, float travelledWorldSpaceDistanceAlongDirection_sinceMouseDown, DrawXXLChartInspector theDrawXXLChartInspector_unserializedMonoB)
{
if (clampTravelledDistance_inThePositiveDirection)
{
if (travelledWorldSpaceDistanceAlongDirection_sinceMouseDown > 0.0f)
{
return Mathf.Min(travelledWorldSpaceDistanceAlongDirection_sinceMouseDown, theDrawXXLChartInspector_unserializedMonoB.GetBacksnapSliderReferenceLength_inWorldspaceUnits());
}
}
return travelledWorldSpaceDistanceAlongDirection_sinceMouseDown;
}
static void TryDrawSpiralSpring(int control_ID, bool drawSpiralSpring, float travelledWorldSpaceDistanceAlongDirection_sinceMouseDown, Vector3 restingPosition, DrawXXLChartInspector theDrawXXLChartInspector_unserializedMonoB, Vector3 sliderDirection_worldSpace_normalized)
{
if (drawSpiralSpring)
{
if (GUIUtility.hotControl == control_ID)
{
HandlesExamples.ConfigureDrawXXLsGlobalSettingsForDrawingHandles();
//Generated via code snippet/live template:
Vector3 start_of_spiral = restingPosition;
Vector3 end_of_spiral = Get_currentPosition_ofOneDimensionalBacksnapSlider(travelledWorldSpaceDistanceAlongDirection_sinceMouseDown, restingPosition, sliderDirection_worldSpace_normalized);
float relaxedLength_of_spiral = theDrawXXLChartInspector_unserializedMonoB.GetBacksnapSliderReferenceLength_inWorldspaceUnits();
Color relaxedColor_of_spiral = Handles.color;
DrawBasics.LineStyle style_of_spiral = DrawBasics.LineStyle.spiral;
float stretchFactor_forStretchedTensionColor_of_spiral = 2.0f;
Color color_forStretchedTension_of_spiral = Handles.color;
float stretchFactor_forSqueezedTensionColor_of_spiral = 0.0f;
Color color_forSqueezedTension_of_spiral = Handles.color;
float width_of_spiral = 0.0f;
string text_of_spiral = null;
float alphaOfReferenceLengthDisplay_of_spiral = 0.5f;
float stylePatternScaleFactor_of_spiral = 0.7f * (theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.Width_inWorldSpace + theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.Height_inWorldSpace);
Vector3 customAmplitudeAndTextDir_of_spiral = default(Vector3);
bool flattenThickRoundLineIntoAmplitudePlane_of_spiral = false;
float endPlates_size_of_spiral = 0.0f;
float enlargeSmallTextToThisMinTextSize_of_spiral = 0.0f;
float durationInSec_of_spiral = 0.0f;
bool hiddenByNearerObjects_of_spiral = true;
bool skipPatternEnlargementForLongLines_of_spiral = true;
bool skipPatternEnlargementForShortLines_of_spiral = true;
float stylePatternScaleFactor_alongLineDir_ignoringAmplitude_before = DrawBasics.StylePatternScaleFactor_alongLineDir_ignoringAmplitude;
DrawBasics.StylePatternScaleFactor_alongLineDir_ignoringAmplitude = 0.6f; //-> Instruct Draw XXL how to use this style scaling for all following draw operations
DrawBasics.LineUnderTension(start_of_spiral, end_of_spiral, relaxedLength_of_spiral, relaxedColor_of_spiral, style_of_spiral, stretchFactor_forStretchedTensionColor_of_spiral, color_forStretchedTension_of_spiral, stretchFactor_forSqueezedTensionColor_of_spiral, color_forSqueezedTension_of_spiral, width_of_spiral, text_of_spiral, alphaOfReferenceLengthDisplay_of_spiral, stylePatternScaleFactor_of_spiral, customAmplitudeAndTextDir_of_spiral, flattenThickRoundLineIntoAmplitudePlane_of_spiral, endPlates_size_of_spiral, enlargeSmallTextToThisMinTextSize_of_spiral, durationInSec_of_spiral, hiddenByNearerObjects_of_spiral, skipPatternEnlargementForLongLines_of_spiral, skipPatternEnlargementForShortLines_of_spiral);
DrawBasics.StylePatternScaleFactor_alongLineDir_ignoringAmplitude = stylePatternScaleFactor_alongLineDir_ignoringAmplitude_before; //-> Revert the Draw XXL setting to what it was before
//Generated via code snippet/live template:
Vector3 position_of_dot = restingPosition;
float radius_of_dot = 0.003f * stylePatternScaleFactor_of_spiral;
Vector3 normal_of_dot = default(Vector3); //-> this will automatically point to the Scene View Camera, because "DrawShapes.automaticOrientationOfFlatShapes" has been set accordingly inside "HandlesExamples.ConfigureDrawXXLsGlobalSettingsForDrawingHandles()"
Color color_of_dot = Handles.color;
string text_of_dot = null;
float density_of_dot = 1.0f;
float durationInSec_of_dot = 0.0f;
bool hiddenByNearerObjects_of_dot = true;
DrawBasics.Dot(position_of_dot, radius_of_dot, normal_of_dot, color_of_dot, text_of_dot, density_of_dot, durationInSec_of_dot, hiddenByNearerObjects_of_dot);
HandlesExamples.RevertDrawXXLsGlobalHandleSettingsToWhatTheyWereBefore();
}
}
}
static void DrawOneDimensionalBacksnapSliderCap(int control_ID, float travelledWorldSpaceDistanceAlongDirection_sinceMouseDown, Vector3 restingPosition, DrawXXLChartInspector theDrawXXLChartInspector_unserializedMonoB, Vector3 sliderDirection_worldSpace_normalized, Handles.CapFunction capFunction, float capSizeScaleFactor, EventType eventType)
{
Vector3 currentPosition_ofBacksnapSlider = Get_currentPosition_ofOneDimensionalBacksnapSlider(travelledWorldSpaceDistanceAlongDirection_sinceMouseDown, restingPosition, sliderDirection_worldSpace_normalized);
float size = GetSizeOfButtonCaps_withoutWeightFactorFromCapTypeApplied(theDrawXXLChartInspector_unserializedMonoB) * capSizeScaleFactor;
Quaternion rotation = Quaternion.LookRotation(sliderDirection_worldSpace_normalized);
capFunction(control_ID, currentPosition_ofBacksnapSlider, rotation, size, eventType);
}
static void DrawIcon_onOneDimensionalBacksnapSlider(float travelledWorldSpaceDistanceAlongDirection_sinceMouseDown, Vector3 restingPosition, DrawXXLChartInspector theDrawXXLChartInspector_unserializedMonoB, Vector3 sliderDirection_worldSpace_normalized, GUIContent icon, float iconSizeFactor, Vector2 iconPositionOffset_inScreenspace_relToHandleCapSize)
{
if (SceneView.lastActiveSceneView != null)
{
float handleCapSize_inWorldSpace = GetSizeOfButtonCaps_withoutWeightFactorFromCapTypeApplied(theDrawXXLChartInspector_unserializedMonoB);
Vector3 worldSpaceOffset_thatShiftsTheIconAlongScreenspaceXDir = SceneView.lastActiveSceneView.camera.transform.right * handleCapSize_inWorldSpace * iconPositionOffset_inScreenspace_relToHandleCapSize.x;
Vector3 worldSpaceOffset_thatShiftsTheIconAlongScreenspaceYDir = SceneView.lastActiveSceneView.camera.transform.up * handleCapSize_inWorldSpace * iconPositionOffset_inScreenspace_relToHandleCapSize.y;
Vector3 iconPosition = Get_currentPosition_ofOneDimensionalBacksnapSlider(travelledWorldSpaceDistanceAlongDirection_sinceMouseDown, restingPosition, sliderDirection_worldSpace_normalized) + worldSpaceOffset_thatShiftsTheIconAlongScreenspaceXDir + worldSpaceOffset_thatShiftsTheIconAlongScreenspaceYDir;
float iconSize_asFloat_inWorldSpace = handleCapSize_inWorldSpace * iconSizeFactor;
Vector2 iconSize_inPixels_asVector2 = ConvertIconSize_fromWorldspaceSize_toPixelSize(iconSize_asFloat_inWorldSpace, iconPosition);
Vector2 iconSize_before = EditorGUIUtility.GetIconSize();
EditorGUIUtility.SetIconSize(iconSize_inPixels_asVector2);
Handles.Label(iconPosition, icon);
EditorGUIUtility.SetIconSize(iconSize_before);
}
}
static Vector3 Get_currentPosition_ofOneDimensionalBacksnapSlider(float travelledWorldSpaceDistanceAlongDirection_sinceMouseDown, Vector3 restingPosition, Vector3 sliderDirection_worldSpace_normalized)
{
return (restingPosition + sliderDirection_worldSpace_normalized * travelledWorldSpaceDistanceAlongDirection_sinceMouseDown);
}
public static void TwoDirectionalBacksnapSlider(ref float travelledWorldSpaceDistanceAlongChartsXDirection_sinceMouseDown, ref float travelledWorldSpaceDistanceAlongChartsYDirection_sinceMouseDown, Vector3 restingPosition, DrawXXLChartInspector theDrawXXLChartInspector_unserializedMonoB, float capSizeScaleFactor, GUIContent icon, float iconSizeFactor, Vector2 iconPositionOffset_inScreenspace_relToHandleCapSize)
{
int control_ID = GUIUtility.GetControlID(FocusType.Passive);
Event currentEvent = Event.current;
switch (currentEvent.GetTypeForControl(control_ID))
{
case EventType.MouseDown:
if ((HandleUtility.nearestControl == control_ID) && (currentEvent.button == 0) && (currentEvent.alt == false))
{
GUIUtility.hotControl = control_ID;
mousePosition_duringMouseDown = currentEvent.mousePosition;
currentMousePosition = currentEvent.mousePosition;
theDrawXXLChartInspector_unserializedMonoB.SaveZoomAndScrollState_onMouseDown();
currentEvent.Use();
EditorGUIUtility.SetWantsMouseJumping(1);
}
break;
case EventType.MouseUp:
if (GUIUtility.hotControl == control_ID)
{
travelledWorldSpaceDistanceAlongChartsXDirection_sinceMouseDown = 0.0f;
travelledWorldSpaceDistanceAlongChartsYDirection_sinceMouseDown = 0.0f;
GUIUtility.hotControl = 0;
currentEvent.Use();
EditorGUIUtility.SetWantsMouseJumping(0);
}
break;
case EventType.MouseDrag:
if (GUIUtility.hotControl == control_ID)
{
currentMousePosition = currentMousePosition + currentEvent.delta;
travelledWorldSpaceDistanceAlongChartsXDirection_sinceMouseDown = HandleUtility.CalcLineTranslation(mousePosition_duringMouseDown, currentMousePosition, restingPosition, theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.xAxis.AxisVector_normalized_inWorldSpace);
travelledWorldSpaceDistanceAlongChartsYDirection_sinceMouseDown = HandleUtility.CalcLineTranslation(mousePosition_duringMouseDown, currentMousePosition, restingPosition, theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.yAxis.AxisVector_normalized_inWorldSpace);
GUI.changed = true;
currentEvent.Use();
}
break;
case EventType.Repaint:
Color color_before = Handles.color;
TrySetColorDuringMouseInteraction(control_ID, theDrawXXLChartInspector_unserializedMonoB, currentEvent);
DrawTwoDimensionalBacksnapSliderCap(control_ID, travelledWorldSpaceDistanceAlongChartsXDirection_sinceMouseDown, travelledWorldSpaceDistanceAlongChartsYDirection_sinceMouseDown, restingPosition, theDrawXXLChartInspector_unserializedMonoB, capSizeScaleFactor, EventType.Repaint);
Handles.color = color_before;
break;
case EventType.Layout:
DrawTwoDimensionalBacksnapSliderCap(control_ID, travelledWorldSpaceDistanceAlongChartsXDirection_sinceMouseDown, travelledWorldSpaceDistanceAlongChartsYDirection_sinceMouseDown, restingPosition, theDrawXXLChartInspector_unserializedMonoB, capSizeScaleFactor, EventType.Layout);
break;
default:
break;
}
DrawIcon_onTwoDimensionalBacksnapSlider(travelledWorldSpaceDistanceAlongChartsXDirection_sinceMouseDown, travelledWorldSpaceDistanceAlongChartsYDirection_sinceMouseDown, restingPosition, theDrawXXLChartInspector_unserializedMonoB, icon, iconSizeFactor, iconPositionOffset_inScreenspace_relToHandleCapSize);
}
static void DrawTwoDimensionalBacksnapSliderCap(int control_ID, float travelledWorldSpaceDistanceAlongChartsXDirection_sinceMouseDown, float travelledWorldSpaceDistanceAlongChartsYDirection_sinceMouseDown, Vector3 restingPosition, DrawXXLChartInspector theDrawXXLChartInspector_unserializedMonoB, float capSizeScaleFactor, EventType eventType)
{
Vector3 currentPosition_ofBacksnapSlider = Get_currentPosition_ofTwoDimensionalBacksnapSlider(travelledWorldSpaceDistanceAlongChartsXDirection_sinceMouseDown, travelledWorldSpaceDistanceAlongChartsYDirection_sinceMouseDown, restingPosition, theDrawXXLChartInspector_unserializedMonoB);
float size = GetSizeOfButtonCaps_withoutWeightFactorFromCapTypeApplied(theDrawXXLChartInspector_unserializedMonoB) * capSizeScaleFactor;
Handles.SphereHandleCap(control_ID, currentPosition_ofBacksnapSlider, Quaternion.identity, size, eventType);
}
static float GetSizeOfButtonCaps_withoutWeightFactorFromCapTypeApplied(DrawXXLChartInspector theDrawXXLChartInspector_unserializedMonoB)
{
return theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.xAxis.Get_fixedConeLength_forBothAxisVectors();
}
static void DrawIcon_onTwoDimensionalBacksnapSlider(float travelledWorldSpaceDistanceAlongChartsXDirection_sinceMouseDown, float travelledWorldSpaceDistanceAlongChartsYDirection_sinceMouseDown, Vector3 restingPosition, DrawXXLChartInspector theDrawXXLChartInspector_unserializedMonoB, GUIContent icon, float iconSizeFactor, Vector2 iconPositionOffset_inScreenspace_relToHandleCapSize)
{
if (SceneView.lastActiveSceneView != null)
{
float handleCapSize_inWorldSpace = GetSizeOfButtonCaps_withoutWeightFactorFromCapTypeApplied(theDrawXXLChartInspector_unserializedMonoB);
Vector3 worldSpaceOffset_thatShiftsTheIconAlongScreenspaceXDir = SceneView.lastActiveSceneView.camera.transform.right * handleCapSize_inWorldSpace * iconPositionOffset_inScreenspace_relToHandleCapSize.x;
Vector3 worldSpaceOffset_thatShiftsTheIconAlongScreenspaceYDir = SceneView.lastActiveSceneView.camera.transform.up * handleCapSize_inWorldSpace * iconPositionOffset_inScreenspace_relToHandleCapSize.y;
Vector3 iconPosition = Get_currentPosition_ofTwoDimensionalBacksnapSlider(travelledWorldSpaceDistanceAlongChartsXDirection_sinceMouseDown, travelledWorldSpaceDistanceAlongChartsYDirection_sinceMouseDown, restingPosition, theDrawXXLChartInspector_unserializedMonoB) + worldSpaceOffset_thatShiftsTheIconAlongScreenspaceXDir + worldSpaceOffset_thatShiftsTheIconAlongScreenspaceYDir;
float iconSize_asFloat_inWorldSpace = handleCapSize_inWorldSpace * iconSizeFactor;
Vector2 iconSize_inPixels_asVector2 = ConvertIconSize_fromWorldspaceSize_toPixelSize(iconSize_asFloat_inWorldSpace, iconPosition);
Vector2 iconSize_before = EditorGUIUtility.GetIconSize();
EditorGUIUtility.SetIconSize(iconSize_inPixels_asVector2);
Handles.Label(iconPosition, icon);
EditorGUIUtility.SetIconSize(iconSize_before);
}
}
static Vector3 Get_currentPosition_ofTwoDimensionalBacksnapSlider(float travelledWorldSpaceDistanceAlongChartsXDirection_sinceMouseDown, float travelledWorldSpaceDistanceAlongChartsYDirection_sinceMouseDown, Vector3 restingPosition, DrawXXLChartInspector theDrawXXLChartInspector_unserializedMonoB)
{
Vector3 dragOffset_alongXAxis = theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.xAxis.AxisVector_normalized_inWorldSpace * travelledWorldSpaceDistanceAlongChartsXDirection_sinceMouseDown;
Vector3 dragOffset_alongYAxis = theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.yAxis.AxisVector_normalized_inWorldSpace * travelledWorldSpaceDistanceAlongChartsYDirection_sinceMouseDown;
return (restingPosition + dragOffset_alongXAxis + dragOffset_alongYAxis);
}
static Vector2 ConvertIconSize_fromWorldspaceSize_toPixelSize(float iconSize_asFloat_inWorldSpace, Vector3 iconPosition)
{
float iconSize_asFloat_inScreenspace0to1 = UtilitiesDXXL_Screenspace.WorldSpaceExtent_to_viewportSpaceExtentRelToScreenHeight(SceneView.lastActiveSceneView.camera, iconPosition, iconSize_asFloat_inWorldSpace);
float iconSize_inPixels = iconSize_asFloat_inScreenspace0to1 * SceneView.lastActiveSceneView.camera.pixelHeight;
return new Vector2(iconSize_inPixels, iconSize_inPixels);
}
static void TrySetColorDuringMouseInteraction(int control_ID, DrawXXLChartInspector theDrawXXLChartInspector_unserializedMonoB, Event currentEvent)
{
if (control_ID == GUIUtility.hotControl)
{
Handles.color = Handles.selectedColor;
}
else
{
if (IsHovering(control_ID, currentEvent))
{
Handles.color = Handles.preselectionColor;
}
else
{
Handles.color = theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.color;
}
}
}
static bool IsHovering(int control_ID, Event currentEvent)
{
return ((GUIUtility.hotControl == 0) && (control_ID == HandleUtility.nearestControl) && (currentEvent.alt == false));
}
public static bool ShowAllButton(bool checkmarkState, Vector3 position, DrawXXLChartInspector theDrawXXLChartInspector_unserializedMonoB, float sizeScaleFactor, GUIContent checkmarkSymbol, GUIContent crossSymbol, float sizeFactor_forCheckmarkIcon, float sizeFactor_forCrossIcon, Vector2 checkmarkIconPositionOffset_inScreenspace_relToHandleCapSize, Vector2 crossIconPositionOffset_inScreenspace_relToHandleCapSize)
{
if (SceneView.lastActiveSceneView == null)
{
return checkmarkState;
}
else
{
Color handlesColor_before = Handles.color;
float size_withoutWeightFactorFromCapTypeApplied = GetSizeOfButtonCaps_withoutWeightFactorFromCapTypeApplied(theDrawXXLChartInspector_unserializedMonoB);
float size_withWeightFactorFromCapTypeAlreadyApplied = size_withoutWeightFactorFromCapTypeApplied * sizeScaleFactor;
float radius_ofButton = 0.5f * size_withWeightFactorFromCapTypeAlreadyApplied;//"0.5f" factor because "Handles.CircleHandleCap" as a 2D cap seems to interpret the specified size as "radius" differently form the 3D caps that interpret it as "diameter".
Handles.color = theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.color;
Vector3 normalOfSolidDisc = (-SceneView.lastActiveSceneView.camera.transform.forward);
Handles.DrawSolidDisc(position, normalOfSolidDisc, radius_ofButton);
GUIContent displayedIcon;
Vector3 worldSpaceOffset_thatShiftsTheIconAlongScreenspaceXDir;
Vector3 worldSpaceOffset_thatShiftsTheIconAlongScreenspaceYDir;
float iconSize_asFloat_inWorldSpace;
if (checkmarkState == true)
{
worldSpaceOffset_thatShiftsTheIconAlongScreenspaceXDir = SceneView.lastActiveSceneView.camera.transform.right * size_withoutWeightFactorFromCapTypeApplied * checkmarkIconPositionOffset_inScreenspace_relToHandleCapSize.x;
worldSpaceOffset_thatShiftsTheIconAlongScreenspaceYDir = SceneView.lastActiveSceneView.camera.transform.up * size_withoutWeightFactorFromCapTypeApplied * checkmarkIconPositionOffset_inScreenspace_relToHandleCapSize.y;
displayedIcon = checkmarkSymbol;
iconSize_asFloat_inWorldSpace = size_withoutWeightFactorFromCapTypeApplied * sizeFactor_forCheckmarkIcon;
}
else
{
worldSpaceOffset_thatShiftsTheIconAlongScreenspaceXDir = SceneView.lastActiveSceneView.camera.transform.right * size_withoutWeightFactorFromCapTypeApplied * crossIconPositionOffset_inScreenspace_relToHandleCapSize.x;
worldSpaceOffset_thatShiftsTheIconAlongScreenspaceYDir = SceneView.lastActiveSceneView.camera.transform.up * size_withoutWeightFactorFromCapTypeApplied * crossIconPositionOffset_inScreenspace_relToHandleCapSize.y;
displayedIcon = crossSymbol;
iconSize_asFloat_inWorldSpace = size_withoutWeightFactorFromCapTypeApplied * sizeFactor_forCrossIcon;
}
Vector3 posOfDisplayedIcon = position + worldSpaceOffset_thatShiftsTheIconAlongScreenspaceXDir + worldSpaceOffset_thatShiftsTheIconAlongScreenspaceYDir;
Vector2 iconSize_inPixels_asVector2 = ConvertIconSize_fromWorldspaceSize_toPixelSize(iconSize_asFloat_inWorldSpace, posOfDisplayedIcon);
Vector2 iconSize_before = EditorGUIUtility.GetIconSize();
EditorGUIUtility.SetIconSize(iconSize_inPixels_asVector2);
Handles.Label(posOfDisplayedIcon, displayedIcon);
EditorGUIUtility.SetIconSize(iconSize_before);
GUIStyle styleFor_showAllText = new GUIStyle();
float textSize_asFloat_inScreenspace0to1 = UtilitiesDXXL_Screenspace.WorldSpaceExtent_to_viewportSpaceExtentRelToScreenHeight(SceneView.lastActiveSceneView.camera, position, 0.7f * size_withoutWeightFactorFromCapTypeApplied);
float textSize_inPixels = textSize_asFloat_inScreenspace0to1 * SceneView.lastActiveSceneView.camera.pixelHeight;
styleFor_showAllText.fontSize = (int)textSize_inPixels;
//styleFor_showAllText.alignment = TextAnchor.UpperCenter; //-> is this a bug in Unity? All anchors with "right" behave as it would be "left". Also "Center" is not really the center, but slightly shifted. I place the text at a manually shifted position as a fallback.
string showAll_labelText = DrawText.MarkupColor("Show all", theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.color);
Vector3 positionOfText = position - SceneView.lastActiveSceneView.camera.transform.right * 3.4f * size_withWeightFactorFromCapTypeAlreadyApplied+ SceneView.lastActiveSceneView.camera.transform.up * 0.4f * size_withWeightFactorFromCapTypeAlreadyApplied;
Handles.Label(positionOfText, showAll_labelText, styleFor_showAllText);
Handles.color = UtilitiesDXXL_Colors.GetSimilarColorWithOtherBrightnessValue(theDrawXXLChartInspector_unserializedMonoB.chart_thisInspectorIsAttachedTo.color);
Quaternion rotation_ofButton = Quaternion.LookRotation(normalOfSolidDisc);
bool buttonHasBeenClicked = Handles.Button(position, rotation_ofButton, radius_ofButton, radius_ofButton, Handles.CircleHandleCap);
if (buttonHasBeenClicked)
{
checkmarkState = !checkmarkState;
}
Handles.color = handlesColor_before;
return checkmarkState;
}
}
}
#endif
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: acd864c428f8f6748ba54e9411c29224
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: