Quellcode durchsuchen

When loading a new scene by double clicking an entry in project window, check if we want to save existing

Marko Pintera vor 10 Jahren
Ursprung
Commit
ba56c82eba
3 geänderte Dateien mit 27 neuen und 33 gelöschten Zeilen
  1. 26 27
      MBansheeEditor/EditorApplication.cs
  2. 1 1
      MBansheeEditor/ProjectWindow.cs
  3. 0 5
      TODO.txt

+ 26 - 27
MBansheeEditor/EditorApplication.cs

@@ -119,8 +119,8 @@ namespace BansheeEditor
             ProjectLibrary.Update();
         }
 
-        [MenuItem("File/Save Prefab", ButtonModifier.Ctrl, ButtonCode.S, 50, true)]
-        private static void SavePrefab()
+        [MenuItem("File/Save Scene", ButtonModifier.Ctrl, ButtonCode.S, 50, true)]
+        private static void SaveScene()
         {
             if (!string.IsNullOrEmpty(Scene.ActiveSceneUUID))
             {
@@ -128,11 +128,11 @@ namespace BansheeEditor
                 Internal_SaveScene(scenePath);
             }
             else
-                SavePrefabAs();
+                SaveSceneAs();
         }
 
-        [MenuItem("File/Save Prefab As", 50)]
-        private static void SavePrefabAs()
+        [MenuItem("File/Save Scene As", 50)]
+        private static void SaveSceneAs()
         {
             string scenePath = "";
             if (BrowseDialog.SaveFile(ProjectLibrary.ResourceFolder, "*.prefab", out scenePath))
@@ -150,31 +150,30 @@ namespace BansheeEditor
             }
         }
 
-        [MenuItem("File/Load Prefab", ButtonModifier.Ctrl, ButtonCode.L, 50)]
-        private static void LoadPrefab()
+        [MenuItem("File/Load Scene", ButtonModifier.Ctrl, ButtonCode.L, 50)]
+        private static void LoadScene()
         {
-            Action doLoad =
-                () =>
-                {
-                    string[] scenePaths;
-                    if (BrowseDialog.OpenFile(ProjectLibrary.ResourceFolder, "", false, out scenePaths))
-                    {
-                        if (scenePaths.Length > 0)
-                            Scene.Load(scenePaths[0]);
-                    }
-                };
+            string[] scenePaths;
+            if (BrowseDialog.OpenFile(ProjectLibrary.ResourceFolder, "", false, out scenePaths))
+            {
+                if (scenePaths.Length > 0)
+                    LoadScene(scenePaths[0]);
+            }
+        }
 
+        public static void LoadScene(string path)
+        {
             Action<DialogBox.ResultType> dialogCallback =
-                (result) =>
+            (result) =>
+            {
+                if (result == DialogBox.ResultType.Yes)
                 {
-                    if (result == DialogBox.ResultType.Yes)
-                    {
-                        SavePrefab();
-                        doLoad();
-                    }
-                    else if (result == DialogBox.ResultType.No)
-                        doLoad();
-                };
+                    SaveScene();
+                    Scene.Load(path);
+                }
+                else if (result == DialogBox.ResultType.No)
+                    Scene.Load(path);
+            };
 
             if (Scene.IsModified())
             {
@@ -182,7 +181,7 @@ namespace BansheeEditor
                     DialogBox.Type.YesNoCancel, dialogCallback);
             }
             else
-                doLoad();
+                Scene.Load(path);
         }
 
         [MenuItem("Components/Camera")]

+ 1 - 1
MBansheeEditor/ProjectWindow.cs

@@ -1208,7 +1208,7 @@ namespace BansheeEditor
                     FileEntry resEntry = (FileEntry) entry;
                     if (resEntry.ResType == ResourceType.Prefab)
                     {
-                        Scene.Load(resEntry.Path);
+                        EditorApplication.LoadScene(resEntry.Path);
                     }
                 }
             }

+ 0 - 5
TODO.txt

@@ -53,11 +53,6 @@ Code quality improvements:
 Polish
 
 Test:
- - Saving a scene seems to create another (unselectable) copy of the dragon mesh
-  - Renderable/Light/Camera components initialize their handlers in constructors
-  - Moving them to OnInitialize doesn't solve the issue because when deserializing
-    those components OnInitialize will then overwrite any deserialized data
- - Loading a saved level doesn't seem to persist scene object positions
  - Loaded scene test component has empty values
  - Loading a scene multiple times causes an exception when updating Renderables in scene manager