protected virtual void OnEnable() { this.point = (BezierPoint3D)this.target; this.handleType = this.serializedObject.FindProperty("handleType"); this.leftHandleLocalPosition = this.serializedObject.FindProperty("leftHandleLocalPosition"); this.rightHandleLocalPosition = this.serializedObject.FindProperty("rightHandleLocalPosition"); }
private static void AddDefaultPoints(BezierCurve3D curve) { BezierPoint3D startPoint = curve.AddKeyPoint(); startPoint.LocalPosition = new Vector3(-1f, 0f, 0f); startPoint.LeftHandleLocalPosition = new Vector3(-0.35f, -0.35f, 0f); BezierPoint3D endPoint = curve.AddKeyPoint(); endPoint.LocalPosition = new Vector3(1f, 0f, 0f); endPoint.LeftHandleLocalPosition = new Vector3(-0.35f, 0.35f, 0f); }
public static void DrawPointsSceneGUI(BezierCurve3D curve, BezierPoint3D exclude = null) { for (int i = 0; i < curve.KeyPointsCount; i++) { if (curve.KeyPoints[i] == exclude) { continue; } BezierPoint3DEditor.handleCapSize = BezierPoint3DEditor.CircleCapSize; BezierPoint3DEditor.DrawPointSceneGUI(curve.KeyPoints[i]); } }
public static void DrawPointSceneGUI(BezierPoint3D point, Handles.CapFunction drawPointFunc, Handles.CapFunction drawHandleFunc) { // Draw a label for the point Handles.color = Color.black; Handles.Label(point.Position + new Vector3(0f, HandleUtility.GetHandleSize(point.Position) * 0.4f, 0f), point.gameObject.name); // Draw the center of the control point Handles.color = Color.yellow; Vector3 newPointPosition = Handles.FreeMoveHandle(point.Position, point.transform.rotation, HandleUtility.GetHandleSize(point.Position) * BezierPoint3DEditor.pointCapSize, Vector3.one * 0.5f, drawPointFunc); if (point.Position != newPointPosition) { Undo.RegisterCompleteObjectUndo(point.transform, "Move Point"); point.Position = newPointPosition; } // Draw the left and right handles Handles.color = Color.white; Handles.DrawLine(point.Position, point.LeftHandlePosition); Handles.DrawLine(point.Position, point.RightHandlePosition); Handles.color = Color.cyan; Vector3 newLeftHandlePosition = Handles.FreeMoveHandle(point.LeftHandlePosition, point.transform.rotation, HandleUtility.GetHandleSize(point.LeftHandlePosition) * BezierPoint3DEditor.handleCapSize, Vector3.zero, drawHandleFunc); if (point.LeftHandlePosition != newLeftHandlePosition) { Undo.RegisterCompleteObjectUndo(point, "Move Left Handle"); point.LeftHandlePosition = newLeftHandlePosition; } Vector3 newRightHandlePosition = Handles.FreeMoveHandle(point.RightHandlePosition, point.transform.rotation, HandleUtility.GetHandleSize(point.RightHandlePosition) * BezierPoint3DEditor.handleCapSize, Vector3.zero, drawHandleFunc); if (point.RightHandlePosition != newRightHandlePosition) { Undo.RegisterCompleteObjectUndo(point, "Move Right Handle"); point.RightHandlePosition = newRightHandlePosition; } }
public static void DrawPointSceneGUI(BezierPoint3D point) { DrawPointSceneGUI(point, Handles.RectangleHandleCap, Handles.CircleHandleCap); }