@@ -61,6 +61,9 @@ public class PathEditor : Editor
6161
6262 Color handlesStartCol ;
6363
64+ private Quaternion handleRotation = Quaternion . identity ;
65+ private bool isSceneViewMouseDown ;
66+
6467 // Constants
6568 const int bezierPathTab = 0 ;
6669 const int vertexPathTab = 1 ;
@@ -134,7 +137,9 @@ void DrawBezierPathInspector()
134137
135138 // If a point has been selected
136139 if ( handleIndexToDisplayAsTransform != - 1 )
137- {
140+ {
141+ UpdateHandleRotation ( handleIndexToDisplayAsTransform ) ;
142+
138143 EditorGUILayout . LabelField ( "Selected Point:" ) ;
139144
140145 using ( new EditorGUI . IndentLevelScope ( ) )
@@ -649,14 +654,12 @@ void DrawHandle(int i)
649654 bezierPath . SetAnchorNormalAngle ( i / 3 , anchorAngleHandle . angle - handleRotOffset ) ;
650655 }
651656 }
652-
653- }
657+ }
654658 else
655659 {
656- handlePosition = Handles . DoPositionHandle ( handlePosition , Quaternion . identity ) ;
660+ handlePosition = Handles . DoPositionHandle ( handlePosition , handleRotation ) ;
657661 }
658-
659- }
662+ }
660663
661664 switch ( handleInputType )
662665 {
@@ -704,11 +707,32 @@ void DrawHandle(int i)
704707 {
705708 Undo . RecordObject ( creator , "Move point" ) ;
706709 bezierPath . MovePoint ( i , localHandlePosition ) ;
707-
708- }
709-
710- }
711-
710+ }
711+ }
712+
713+ private void UpdateHandleRotation ( int i )
714+ {
715+ var rot = Quaternion . identity ;
716+ if ( Tools . pivotRotation == PivotRotation . Local )
717+ {
718+ var i3 = i % 3 ;
719+
720+ var t = creator . path . GetClosestTimeOnPath ( bezierPath . GetPoint ( i ) ) ;
721+ rot = creator . path . GetRotation ( t , bezierPath . IsClosed ? EndOfPathInstruction . Loop : EndOfPathInstruction . Stop ) ;
722+ if ( i3 != 0 )
723+ {
724+ var anchorIndex = 0 ;
725+ if ( i3 == 1 )
726+ anchorIndex = i - 1 ;
727+ else if ( i3 == 2 )
728+ anchorIndex = i + 1 ;
729+
730+ rot = Quaternion . LookRotation ( bezierPath . GetPoint ( i ) - bezierPath . GetPoint ( anchorIndex ) , rot * Vector3 . up ) ;
731+ }
732+ }
733+ handleRotation = rot ;
734+ }
735+
712736 #endregion
713737
714738 #region Internal methods
0 commit comments