예제 #1
0
 public override void OnInspectorGUI()
 {
     DrawDefaultInspector();
     hSpline = target as HermiteSplineMonoBehaviour;
     if (GUILayout.Button("Add Curve"))
     {
         Undo.RecordObject(hSpline, "Add Curve");
         hSpline.AddControlPoint();
         EditorUtility.SetDirty(hSpline);
     }
 }
예제 #2
0
    private void OnSceneGUI()
    {
        hSpline          = target as HermiteSplineMonoBehaviour;
        hSplineTransform = hSpline.transform;
        hSplineRotation  = hSplineTransform.rotation;

        if (hSpline.Spline == null)
        {
            return;
        }

        Vector3 p0 = ShowPositionPoint(0);
        Vector3 p1 = ShowTangentPoint(0);

        for (int i = 1; i < hSpline.Spline.GetControlPointCount(); i++)
        {
            Vector3 p2 = ShowPositionPoint(i);
            Vector3 p3 = ShowTangentPoint(i);

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

            p0 = p2;
            p1 = p3;
        }

        Handles.color = Color.grey;
        Vector3 lineStart = hSpline.GetPoint(0f);

        for (int i = 1; i <= lineSteps; i++)
        {
            Vector3 lineEnd = hSpline.GetPoint(i / (float)lineSteps);
            Handles.DrawLine(lineStart, lineEnd);
            lineStart = lineEnd;
        }
    }