示例#1
0
 public override void OnInspectorGUI()
 {
     DrawDefaultInspector();
     curve = target as JGSpline;
     if (GUILayout.Button("Add Curve"))
     {
         Undo.RecordObject(curve, "Add Curve");
         curve.AddCurve();
         EditorUtility.SetDirty(curve);
     }
 }
示例#2
0
    private void OnSceneGUI()
    {
        curve      = target as JGSpline;
        cTransform = curve.transform;
        cRotation  = Tools.pivotRotation == PivotRotation.Local ? cTransform.rotation : Quaternion.identity;

        //Loop
        Vector3 p0 = ShowPoint(0);

        for (int i = 1; i < curve.points.Length; i += 3)
        {
            Vector3 p1 = ShowPoint(i);
            Vector3 p2 = ShowPoint(i + 1);
            Vector3 p3 = ShowPoint(i + 2);

            Handles.color = Color.grey;
            Handles.DrawLine(p0, p1);
            Handles.DrawLine(p2, p3);

            Handles.DrawBezier(p0, p3, p1, p2, Color.white, null, 2f);
            p0 = p3;
        }

        ShowDirections();

        /* not needed because of Handles.DrawBezier
         * Handles.color = Color.green;
         * Vector3 lineStart = curve.GetPoint (0f);
         * Handles.DrawLine (lineStart, lineStart + curve.GetDirection (0f));
         * for (int i = 1; i <= lineSteps; i++) {
         *      Handles.color = Color.red;
         *      Vector3 lineEnd = curve.GetPoint (i / (float)lineSteps);
         *      Handles.DrawLine (lineStart, lineEnd);
         *      Handles.color = Color.green;
         *      Handles.DrawLine (lineEnd, lineEnd + curve.GetDirection (i / (float)lineSteps));
         *      lineStart = lineEnd;
         * }
         */
    }