Bladeren bron

Fixed an issue with scene saving where saving a scene over an existing scene chooses an incorrect filename
Saving a new scene now properly makes the scene active right away

BearishSun 10 jaren geleden
bovenliggende
commit
a836ff4e68

+ 5 - 3
MBansheeEditor/EditorApplication.cs

@@ -325,7 +325,7 @@ namespace BansheeEditor
                     // TODO - If path points to an existing non-scene asset or folder I should delete it otherwise
                     // TODO - If path points to an existing non-scene asset or folder I should delete it otherwise
                     //        Internal_SaveScene will silently fail.
                     //        Internal_SaveScene will silently fail.
 
 
-                    scenePath += ".prefab";
+                    scenePath = Path.ChangeExtension(scenePath, ".prefab");
                     SaveScene(scenePath);
                     SaveScene(scenePath);
                 }
                 }
             }
             }
@@ -387,7 +387,9 @@ namespace BansheeEditor
         ///                    prefab if it just needs updating. </param>
         ///                    prefab if it just needs updating. </param>
         public static void SaveScene(string path)
         public static void SaveScene(string path)
         {
         {
-            Internal_SaveScene(path);
+            Prefab scene = Internal_SaveScene(path);
+            Scene.SetActive(scene);
+
             ProjectLibrary.Refresh(true);
             ProjectLibrary.Refresh(true);
             SetSceneDirty(false);
             SetSceneDirty(false);
         }
         }
@@ -783,7 +785,7 @@ namespace BansheeEditor
         private static extern string Internal_GetScriptEditorAssemblyName();
         private static extern string Internal_GetScriptEditorAssemblyName();
 
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern string Internal_SaveScene(string path);
+        private static extern Prefab Internal_SaveScene(string path);
 
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern bool Internal_IsValidProject(string path);
         private static extern bool Internal_IsValidProject(string path);

+ 9 - 0
MBansheeEngine/Scene.cs

@@ -64,6 +64,15 @@ namespace BansheeEngine
             Clear();
             Clear();
             Prefab scene = Internal_LoadScene(path);
             Prefab scene = Internal_LoadScene(path);
 
 
+            SetActive(scene);
+        }
+
+        /// <summary>
+        /// Sets the currently active scene to the provided scene.
+        /// </summary>
+        /// <param name="scene">Scene which to set as active.</param>
+        internal static void SetActive(Prefab scene)
+        {
             if (scene != null)
             if (scene != null)
             {
             {
                 activeSceneUUID = scene.UUID;
                 activeSceneUUID = scene.UUID;

+ 1 - 1
SBansheeEditor/Include/BsScriptEditorApplication.h

@@ -59,7 +59,7 @@ namespace BansheeEngine
 		static MonoString* internal_GetEditorAssemblyName();
 		static MonoString* internal_GetEditorAssemblyName();
 		static MonoString* internal_GetScriptGameAssemblyName();
 		static MonoString* internal_GetScriptGameAssemblyName();
 		static MonoString* internal_GetScriptEditorAssemblyName();
 		static MonoString* internal_GetScriptEditorAssemblyName();
-		static MonoString* internal_SaveScene(MonoString* path);
+		static MonoObject* internal_SaveScene(MonoString* path);
 		static bool internal_IsValidProject(MonoString* path);
 		static bool internal_IsValidProject(MonoString* path);
 		static void internal_SaveProject();
 		static void internal_SaveProject();
 		static void internal_LoadProject(MonoString* path);
 		static void internal_LoadProject(MonoString* path);

+ 7 - 2
SBansheeEditor/Source/BsScriptEditorApplication.cpp

@@ -17,7 +17,9 @@
 #include "BsGUIMenuBar.h"
 #include "BsGUIMenuBar.h"
 #include "BsPlayInEditorManager.h"
 #include "BsPlayInEditorManager.h"
 #include "BsScriptRenderTarget.h"
 #include "BsScriptRenderTarget.h"
+#include "BsScriptResourceManager.h"
 #include "BsFileSystem.h"
 #include "BsFileSystem.h"
+#include "BsScriptPrefab.h"
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
@@ -209,7 +211,7 @@ namespace BansheeEngine
 		return MonoUtil::wstringToMono(toWString(SCRIPT_EDITOR_ASSEMBLY) + L".dll");
 		return MonoUtil::wstringToMono(toWString(SCRIPT_EDITOR_ASSEMBLY) + L".dll");
 	}
 	}
 
 
-	MonoString* ScriptEditorApplication::internal_SaveScene(MonoString* path)
+	MonoObject* ScriptEditorApplication::internal_SaveScene(MonoString* path)
 	{
 	{
 		Path nativePath = MonoUtil::monoToWString(path);
 		Path nativePath = MonoUtil::monoToWString(path);
 		HSceneObject sceneRoot = gSceneManager().getRootNode();
 		HSceneObject sceneRoot = gSceneManager().getRootNode();
@@ -236,7 +238,10 @@ namespace BansheeEngine
 			gProjectLibrary().createEntry(scene, nativePath);
 			gProjectLibrary().createEntry(scene, nativePath);
 		}
 		}
 
 
-		return MonoUtil::stringToMono(scene.getUUID());
+		ScriptPrefab* scriptPrefab;
+		ScriptResourceManager::instance().getScriptResource(scene, &scriptPrefab, true);
+
+		return scriptPrefab->getManagedInstance();
 	}
 	}
 
 
 	bool ScriptEditorApplication::internal_IsValidProject(MonoString* path)
 	bool ScriptEditorApplication::internal_IsValidProject(MonoString* path)

+ 1 - 0
TODO.txt

@@ -40,6 +40,7 @@ Optional:
  - Test VS 2015 Community as code editor (possibly also move the code to VS 2015)
  - Test VS 2015 Community as code editor (possibly also move the code to VS 2015)
 
 
  More optional:
  More optional:
+ - Clearing the console should also clear the status bar
  - When starting drag from hierarchy tree view it tends to select another object (can't repro)
  - When starting drag from hierarchy tree view it tends to select another object (can't repro)
  - Handle seems to lag behind the selected mesh
  - Handle seems to lag behind the selected mesh
  - When starting play-in-editor, automatically make the Game Window active
  - When starting play-in-editor, automatically make the Game Window active