Skip to content

Commit db2b92d

Browse files
Implementing pull request SebLague#79 from salexivich
Displaying labels for anchor numbers SebLague#79
1 parent cb5a992 commit db2b92d

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

Assets/PathCreator/Core/Editor/PathEditor.cs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,12 @@ void DrawBezierPathInspector()
237237
data.showPathBounds = GUILayout.Toggle(data.showPathBounds, new GUIContent("Show Path Bounds"));
238238
data.showPerSegmentBounds = GUILayout.Toggle(data.showPerSegmentBounds, new GUIContent("Show Segment Bounds"));
239239
data.displayAnchorPoints = GUILayout.Toggle(data.displayAnchorPoints, new GUIContent("Show Anchor Points"));
240+
241+
if (data.displayAnchorPoints)
242+
{
243+
data.displayAnchorNumbers = GUILayout.Toggle(data.displayAnchorNumbers, new GUIContent("Show Anchor Numbers"));
244+
}
245+
240246
if (!(bezierPath.ControlPointMode == BezierPath.ControlMode.Automatic && globalDisplaySettings.hideAutoControls))
241247
{
242248
data.displayControlPoints = GUILayout.Toggle(data.displayControlPoints, new GUIContent("Show Control Points"));
@@ -366,8 +372,7 @@ void OnSceneGUI()
366372

367373
void DrawVertexPathSceneEditor()
368374
{
369-
370-
Color bezierCol = globalDisplaySettings.bezierPath;
375+
Color bezierCol = globalDisplaySettings.bezierPath;
371376
bezierCol.a *= .5f;
372377

373378
if (data.showBezierPathInVertexMode)
@@ -379,6 +384,7 @@ void DrawVertexPathSceneEditor()
379384
{
380385
points[j] = MathUtility.TransformPoint(points[j], creator.transform, bezierPath.Space);
381386
}
387+
382388
Handles.DrawBezier(points[0], points[3], points[1], points[2], bezierCol, null, 2);
383389
}
384390
}
@@ -519,8 +525,7 @@ void ProcessBezierPathInput(Event e)
519525

520526
void DrawBezierPathSceneEditor()
521527
{
522-
523-
bool displayControlPoints = data.displayControlPoints && (bezierPath.ControlPointMode != BezierPath.ControlMode.Automatic || !globalDisplaySettings.hideAutoControls);
528+
bool displayControlPoints = data.displayControlPoints && (bezierPath.ControlPointMode != BezierPath.ControlMode.Automatic || !globalDisplaySettings.hideAutoControls);
524529
Bounds bounds = bezierPath.CalculateBoundsWithTransform(creator.transform);
525530

526531
if (Event.current.type == EventType.Repaint)
@@ -661,6 +666,22 @@ void DrawHandle(int i)
661666
}
662667
}
663668

669+
if (isAnchorPoint && data.displayAnchorNumbers)
670+
{
671+
var handleNumberText = $"{i / 3 + 1}";
672+
673+
GUIStyle handleNumberTextStyle = new GUIStyle
674+
{
675+
normal =
676+
{
677+
textColor = globalDisplaySettings.anchorNumberColor
678+
},
679+
fontSize = globalDisplaySettings.anchorNumberSize
680+
};
681+
682+
Handles.Label(handlePosition, handleNumberText, handleNumberTextStyle);
683+
}
684+
664685
switch (handleInputType)
665686
{
666687
case PathHandle.HandleInputType.LMBDrag:

Assets/PathCreator/Core/Runtime/Objects/GlobalDisplaySettings.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ public enum HandleType { Sphere, Circle, Square };
2929
public Color anchorHighlighted = new Color(1, 0.57f, 0.4f);
3030
public Color anchorSelected = Color.white;
3131

32+
[Header("Anchor Numbers")]
33+
public int anchorNumberSize = 14;
34+
public Color anchorNumberColor = Color.white;
35+
3236
[Header("Control Colours")]
3337
public Color control = new Color(0.35f, 0.6f, 1, 0.85f);
3438
public Color controlHighlighted = new Color(0.8f, 0.67f, 0.97f);

Assets/PathCreator/Core/Runtime/Objects/PathCreatorData.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class PathCreatorData {
2525
public bool showPathBounds;
2626
public bool showPerSegmentBounds;
2727
public bool displayAnchorPoints = true;
28+
public bool displayAnchorNumbers = true;
2829
public bool displayControlPoints = true;
2930
public float bezierHandleScale = 1;
3031
public bool globalDisplaySettingsFoldout;

0 commit comments

Comments
 (0)