Exemplo n.º 1
0
 void OnEnable()
 {
     curve = target as SceneCurve;
     if (curve && !curve.Created)
     {
         curve.SetInitial();
     }
 }
Exemplo n.º 2
0
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();
            if (!curve)
            {
                curve = target as SceneCurve;
            }
            if (!curve)
            {
                return;
            }
            DrawPointsInspector();

            if (selectedIndex >= 0 && selectedIndex < curve.HandlesCount - 1)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Press to add or remove curve control point.");

                if (GUILayout.Button("Add Point"))
                {
                    Undo.RecordObject(curve, "Add Point");
                    EditorUtility.SetDirty(curve);
                    curve.AddPoint(selectedIndex);
                }

                if (curve.HandlesCount > 3)
                {
                    if (GUILayout.Button("Remove Point"))
                    {
                        Undo.RecordObject(curve, "Remove Point");
                        EditorUtility.SetDirty(curve);
                        curve.RemovePoint(selectedIndex);
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            if (selectedIndex >= 0 && selectedIndex < curve.HandlesCount)
            {
                DrawSelectedPointInspector();
            }
            else
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Select curve control point for curve edit.");
                EditorGUILayout.EndHorizontal();
            }

            if (!curve.Created)
            {
                if (GUILayout.Button("Create curve"))
                {
                    curve.SetInitial();
                }
            }
            else
            {
                if (GUILayout.Button("Rebuild curve"))
                {
                    curve.SetInitial();
                }
            }
        }