Example #1
0
        private void CurveEditor()
        {
            if (spline == null)
            {
                spline = master.spline;
            }

            EditorGUI.BeginChangeCheck();

            if (GUILayout.Button("Add Curve"))
            {
                Undo.RecordObject(spline, "Add Curve");
                spline.AddCurve();
                EditorUtility.SetDirty(spline);
            }
            if (GUILayout.Button("Remove Curve"))
            {
                Undo.RecordObject(spline, "Remove Curve");
                spline.RemoveCurve(selectedIndex);
                selectedIndex = -1;
                EditorUtility.SetDirty(spline);
            }
            if (GUILayout.Button("Reset"))
            {
                Undo.RecordObject(spline, "Reset");
                spline.Reset();
                master.Reset();
                selectedIndex = -1;
                EditorUtility.SetDirty(spline);
            }
            //Debug.Log("begin vertical");
            GUILayout.BeginVertical("box");
            GUILayout.Space(5);
            bool loop = EditorGUILayout.Toggle("Loop", spline.Loop);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(spline, "Toggle Loop");
                EditorUtility.SetDirty(spline);
                spline.Loop = loop;
            }

            GUILayout.Label("    Curve Lenght: " + spline.GetCurveLenght());
            GUILayout.Space(5);
            GUILayout.EndVertical();

            if (selectedIndex >= 0 && selectedIndex < spline.ControlPointCount)
            {
                DrawSelectedPointInspector();
                Debug.Log("Draw selected point");
            }
            else
            {
                //Debug.Log("else");
                GUILayout.BeginVertical("box");
                GUILayout.Space(5);
                GUILayout.Label("   Select point to edit!");
                GUILayout.Space(5);
                GUILayout.EndVertical();
            }
        }