示例#1
0
 public void Cancel()
 {
     if (lastClosed)
     {
         computer.Close();
     }
     else
     {
         computer.Break();
     }
     computer.SetPoints(lastPoints, SplineComputer.Space.Local);
     computer.type = lastType;
 }
示例#2
0
 protected void Revert()
 {
     if (lastClosed)
     {
         computer.Close();
     }
     else
     {
         computer.Break();
     }
     computer.SetPoints(lastPoints, SplineComputer.Space.Local);
     computer.type = lastType;
 }
示例#3
0
        void Presets()
        {
            if (presets == null)
            {
                return;
            }
            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.BeginScrollView(scroll, GUILayout.Width(position.width * 0.35f), GUILayout.MaxHeight(10 * 22));
            if (presets.Length == 0)
            {
                EditorGUILayout.HelpBox("No saved presets available", MessageType.Info);
            }
            for (int i = 0; i < presets.Length; i++)
            {
                EditorGUILayout.BeginHorizontal();
                if (SplineEditorGUI.EditorLayoutSelectableButton(new GUIContent(presets[i].name), true, presetIndex == i))
                {
                    Undo.RecordObject(this, "PresetsWindow state");
                    Undo.RecordObject(computer, "Spline state");
                    presetIndex    = i;
                    primitiveIndex = -1;
                    computer.SetPoints(presets[i].points);
                    ((SplineEditor)editor).Refresh();
                    computer.type = presets[i].type;
                    if (presets[i].isClosed)
                    {
                        computer.Close();
                    }
                    else
                    {
                        computer.Break();
                    }
                    SplineUser[] users = computer.GetComponents <SplineUser>();
                    foreach (SplineUser user in users)
                    {
                        user.Rebuild(true);
                    }
                    computer.Rebuild();
                    ((SplineEditor)editor).Refresh();
                    SceneView.RepaintAll();
                }
                if (GUILayout.Button("X", GUILayout.MaxWidth(30)))
                {
                    if (EditorUtility.DisplayDialog("Delete preset ?", "Do you want to delete this preset ? This action cannot be undone.", "Yes", "No"))
                    {
                        SplinePreset.Delete(presets[i].filename);
                        GetPresets();
                        if (presetIndex >= presets.Length)
                        {
                            presetIndex = -1;
                        }
                        break;
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            if (GUILayout.Button("Create Preset"))
            {
                presetIndex = -1;
                newPreset   = new SplinePreset(computer.GetPoints(), computer.isClosed, computer.type);
                GetPresets();
            }
            EditorGUILayout.EndScrollView();

            if (presetIndex >= 0 && presetIndex < presets.Length)
            {
                EditorGUILayout.BeginVertical();
                EditorGUILayout.LabelField(presets[presetIndex].name);
                EditorGUILayout.LabelField(presets[presetIndex].description);
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("Save"))
                {
                    computer.Rebuild();
                    ((SplineEditor)editor).Refresh();
                    SceneView.RepaintAll();
                    presetIndex = -1;
                    this.Close();
                }
                if (GUILayout.Button("Cancel"))
                {
                    presets[presetIndex].Cancel();
                    presetIndex = -1;
                    SplineUser[] users = computer.GetComponents <SplineUser>();
                    foreach (SplineUser user in users)
                    {
                        user.Rebuild(true);
                    }
                    computer.Rebuild();
                    ((SplineEditor)editor).Refresh();
                    SceneView.RepaintAll();
                }
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.EndVertical();
            }
            else if (computer.pointCount > 0)
            {
                EditorGUILayout.BeginVertical();
                if (newPreset != null)
                {
                    SavePresetDialog();
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndHorizontal();
        }