Skip to content

Commit

Permalink
Implementing pull request SebLague#79 from salexivich
Browse files Browse the repository at this point in the history
Displaying labels for anchor numbers SebLague#79
  • Loading branch information
JerryVerhoeven committed Sep 19, 2023
1 parent cb5a992 commit db2b92d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
29 changes: 25 additions & 4 deletions Assets/PathCreator/Core/Editor/PathEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,12 @@ void DrawBezierPathInspector()
data.showPathBounds = GUILayout.Toggle(data.showPathBounds, new GUIContent("Show Path Bounds"));
data.showPerSegmentBounds = GUILayout.Toggle(data.showPerSegmentBounds, new GUIContent("Show Segment Bounds"));
data.displayAnchorPoints = GUILayout.Toggle(data.displayAnchorPoints, new GUIContent("Show Anchor Points"));

if (data.displayAnchorPoints)
{
data.displayAnchorNumbers = GUILayout.Toggle(data.displayAnchorNumbers, new GUIContent("Show Anchor Numbers"));
}

if (!(bezierPath.ControlPointMode == BezierPath.ControlMode.Automatic && globalDisplaySettings.hideAutoControls))
{
data.displayControlPoints = GUILayout.Toggle(data.displayControlPoints, new GUIContent("Show Control Points"));
Expand Down Expand Up @@ -366,8 +372,7 @@ void OnSceneGUI()

void DrawVertexPathSceneEditor()
{

Color bezierCol = globalDisplaySettings.bezierPath;
Color bezierCol = globalDisplaySettings.bezierPath;
bezierCol.a *= .5f;

if (data.showBezierPathInVertexMode)
Expand All @@ -379,6 +384,7 @@ void DrawVertexPathSceneEditor()
{
points[j] = MathUtility.TransformPoint(points[j], creator.transform, bezierPath.Space);
}

Handles.DrawBezier(points[0], points[3], points[1], points[2], bezierCol, null, 2);
}
}
Expand Down Expand Up @@ -519,8 +525,7 @@ void ProcessBezierPathInput(Event e)

void DrawBezierPathSceneEditor()
{

bool displayControlPoints = data.displayControlPoints && (bezierPath.ControlPointMode != BezierPath.ControlMode.Automatic || !globalDisplaySettings.hideAutoControls);
bool displayControlPoints = data.displayControlPoints && (bezierPath.ControlPointMode != BezierPath.ControlMode.Automatic || !globalDisplaySettings.hideAutoControls);
Bounds bounds = bezierPath.CalculateBoundsWithTransform(creator.transform);

if (Event.current.type == EventType.Repaint)
Expand Down Expand Up @@ -661,6 +666,22 @@ void DrawHandle(int i)
}
}

if (isAnchorPoint && data.displayAnchorNumbers)
{
var handleNumberText = $"{i / 3 + 1}";

GUIStyle handleNumberTextStyle = new GUIStyle
{
normal =
{
textColor = globalDisplaySettings.anchorNumberColor
},
fontSize = globalDisplaySettings.anchorNumberSize
};

Handles.Label(handlePosition, handleNumberText, handleNumberTextStyle);
}

switch (handleInputType)
{
case PathHandle.HandleInputType.LMBDrag:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public enum HandleType { Sphere, Circle, Square };
public Color anchorHighlighted = new Color(1, 0.57f, 0.4f);
public Color anchorSelected = Color.white;

[Header("Anchor Numbers")]
public int anchorNumberSize = 14;
public Color anchorNumberColor = Color.white;

[Header("Control Colours")]
public Color control = new Color(0.35f, 0.6f, 1, 0.85f);
public Color controlHighlighted = new Color(0.8f, 0.67f, 0.97f);
Expand Down
1 change: 1 addition & 0 deletions Assets/PathCreator/Core/Runtime/Objects/PathCreatorData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class PathCreatorData {
public bool showPathBounds;
public bool showPerSegmentBounds;
public bool displayAnchorPoints = true;
public bool displayAnchorNumbers = true;
public bool displayControlPoints = true;
public float bezierHandleScale = 1;
public bool globalDisplaySettingsFoldout;
Expand Down

0 comments on commit db2b92d

Please sign in to comment.