Skip to content

Commit 7309180

Browse files
committed
Added options to hide end point indices and control point directions from Scene window
1 parent ca6912d commit 7309180

File tree

2 files changed

+61
-3
lines changed

2 files changed

+61
-3
lines changed

Plugins/BezierSolution/Editor/BezierUtils.cs

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public static class BezierUtils
3535
private const string FOLLOWING_CONTROL_POINT_LABEL = " -->";
3636

3737
private const string SHOW_CONTROL_POINTS_PREF = "BezierSolution_ShowControlPoints";
38+
private const string SHOW_CONTROL_POINT_DIRECTIONS_PREF = "BezierSolution_ShowControlPointDirs";
39+
private const string SHOW_END_POINTS_LABELS_PREF = "BezierSolution_ShowEndPointLabels";
3840
private const string SHOW_NORMALS_PREF = "BezierSolution_ShowNormals";
3941

4042
private static bool? m_showControlPoints = null;
@@ -54,6 +56,40 @@ public static bool ShowControlPoints
5456
}
5557
}
5658

59+
private static bool? m_showControlPointDirections = null;
60+
public static bool ShowControlPointDirections
61+
{
62+
get
63+
{
64+
if( m_showControlPointDirections == null )
65+
m_showControlPointDirections = EditorPrefs.GetBool( SHOW_CONTROL_POINT_DIRECTIONS_PREF, true );
66+
67+
return m_showControlPointDirections.Value;
68+
}
69+
set
70+
{
71+
m_showControlPointDirections = value;
72+
EditorPrefs.SetBool( SHOW_CONTROL_POINT_DIRECTIONS_PREF, value );
73+
}
74+
}
75+
76+
private static bool? m_showEndPointLabels = null;
77+
public static bool ShowEndPointLabels
78+
{
79+
get
80+
{
81+
if( m_showEndPointLabels == null )
82+
m_showEndPointLabels = EditorPrefs.GetBool( SHOW_END_POINTS_LABELS_PREF, true );
83+
84+
return m_showEndPointLabels.Value;
85+
}
86+
set
87+
{
88+
m_showEndPointLabels = value;
89+
EditorPrefs.SetBool( SHOW_END_POINTS_LABELS_PREF, value );
90+
}
91+
}
92+
5793
private static bool? m_showNormals = null;
5894
public static bool ShowNormals
5995
{
@@ -274,6 +310,27 @@ public static void DrawSplineInspectorGUI( BezierSpline[] splines )
274310
SceneView.RepaintAll();
275311
}
276312

313+
if( showControlPoints )
314+
{
315+
EditorGUI.indentLevel++;
316+
EditorGUI.BeginChangeCheck();
317+
bool showControlPointDirections = EditorGUILayout.Toggle( "Show Directions", ShowControlPointDirections );
318+
if( EditorGUI.EndChangeCheck() )
319+
{
320+
ShowControlPointDirections = showControlPointDirections;
321+
SceneView.RepaintAll();
322+
}
323+
EditorGUI.indentLevel--;
324+
}
325+
326+
EditorGUI.BeginChangeCheck();
327+
bool showEndPointLabels = EditorGUILayout.Toggle( "Show Point Indices", ShowEndPointLabels );
328+
if( EditorGUI.EndChangeCheck() )
329+
{
330+
ShowEndPointLabels = showEndPointLabels;
331+
SceneView.RepaintAll();
332+
}
333+
277334
EditorGUI.BeginChangeCheck();
278335
bool showNormals = EditorGUILayout.Toggle( "Show Normals", ShowNormals );
279336
if( EditorGUI.EndChangeCheck() )
@@ -437,9 +494,10 @@ public static void DrawBezierPoint( BezierPoint point, int pointIndex, bool isSe
437494
Handles.color = c;
438495
}
439496

440-
Handles.Label( point.position, "Point" + pointIndex );
497+
if( ShowEndPointLabels )
498+
Handles.Label( point.position, "Point" + pointIndex );
441499

442-
if( ShowControlPoints )
500+
if( ShowControlPoints && ShowControlPointDirections )
443501
{
444502
Handles.Label( point.precedingControlPointPosition, PRECEDING_CONTROL_POINT_LABEL );
445503
Handles.Label( point.followingControlPointPosition, FOLLOWING_CONTROL_POINT_LABEL );

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.yasirkula.beziersolution",
33
"displayName": "Bezier Solution",
4-
"version": "2.0.0",
4+
"version": "2.0.1",
55
"documentationUrl": "https://github.com/yasirkula/UnityBezierSolution",
66
"changelogUrl": "https://github.com/yasirkula/UnityBezierSolution/releases",
77
"licensesUrl": "https://github.com/yasirkula/UnityBezierSolution/blob/master/LICENSE.txt",

0 commit comments

Comments
 (0)