Explorar o código

Fixed an issue where closing & opening the scene window was causing a crash because editor application was holding an instance to the old version

Marko Pintera %!s(int64=10) %!d(string=hai) anos
pai
achega
4f09002f28

+ 3 - 6
MBansheeEditor/EditorApplication.cs

@@ -52,7 +52,7 @@ namespace BansheeEditor
 
 
         public static Camera SceneViewCamera
         public static Camera SceneViewCamera
         {
         {
-            get { return instance.scene.GetCamera(); }
+            get { return EditorWindow.GetWindow<SceneWindow>().GetCamera(); }
         }
         }
 
 
         public static EditorPlatformType EditorPlatform
         public static EditorPlatformType EditorPlatform
@@ -73,9 +73,6 @@ namespace BansheeEditor
 
 
         private static EditorApplication instance;
         private static EditorApplication instance;
 
 
-        private InspectorWindow inspector;
-        private SceneWindow scene;
-
         private FolderMonitor monitor;
         private FolderMonitor monitor;
 
 
         // DEBUG ONLY
         // DEBUG ONLY
@@ -103,8 +100,8 @@ namespace BansheeEditor
             inputConfig.RegisterAxis(SceneCamera.VerticalAxisBinding, InputAxis.MouseY);
             inputConfig.RegisterAxis(SceneCamera.VerticalAxisBinding, InputAxis.MouseY);
 
 
             // Open windows
             // Open windows
-            inspector = EditorWindow.OpenWindow<InspectorWindow>();
-            scene = EditorWindow.OpenWindow<SceneWindow>();
+            InspectorWindow inspector = EditorWindow.OpenWindow<InspectorWindow>();
+            EditorWindow.OpenWindow<SceneWindow>();
 
 
             ProjectLibrary.Refresh();
             ProjectLibrary.Refresh();
             monitor = new FolderMonitor(ProjectLibrary.ResourceFolder);
             monitor = new FolderMonitor(ProjectLibrary.ResourceFolder);

+ 8 - 0
MBansheeEditor/EditorWindow.cs

@@ -18,6 +18,11 @@ namespace BansheeEditor
             return (T)Internal_CreateOrGetInstance(typeof(T).Namespace, typeof(T).Name);
             return (T)Internal_CreateOrGetInstance(typeof(T).Namespace, typeof(T).Name);
         }
         }
 
 
+        public static T GetWindow<T>() where T : EditorWindow
+        {
+            return (T)Internal_GetInstance(typeof(T).Namespace, typeof(T).Name);
+        }
+
         public Vector2I ScreenToWindowPos(Vector2I screenPos)
         public Vector2I ScreenToWindowPos(Vector2I screenPos)
         {
         {
             Vector2I windowPos;
             Vector2I windowPos;
@@ -45,6 +50,9 @@ namespace BansheeEditor
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern EditorWindow Internal_CreateOrGetInstance(string ns, string typeName);
         private static extern EditorWindow Internal_CreateOrGetInstance(string ns, string typeName);
 
 
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern EditorWindow Internal_GetInstance(string ns, string typeName);
+
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern int Internal_GetWidth(IntPtr nativeInstance);
         private static extern int Internal_GetWidth(IntPtr nativeInstance);
 
 

+ 1 - 0
MBansheeEditor/Scene/SceneWindow.cs

@@ -125,6 +125,7 @@ namespace BansheeEditor
             if (camera != null)
             if (camera != null)
             {
             {
                 camera.SceneObject.Destroy();
                 camera.SceneObject.Destroy();
+                camera = null;
             }
             }
         }
         }
 
 

+ 1 - 0
SBansheeEditor/Include/BsScriptEditorWindow.h

@@ -33,6 +33,7 @@ namespace BansheeEngine
 		ScriptEditorWindow(ScriptEditorWidget* editorWidget);
 		ScriptEditorWindow(ScriptEditorWidget* editorWidget);
 
 
 		static MonoObject* internal_createOrGetInstance(MonoString* ns, MonoString* typeName);
 		static MonoObject* internal_createOrGetInstance(MonoString* ns, MonoString* typeName);
+		static MonoObject* internal_getInstance(MonoString* ns, MonoString* typeName);
 
 
 		static bool internal_hasFocus(ScriptEditorWindow* thisPtr);
 		static bool internal_hasFocus(ScriptEditorWindow* thisPtr);
 		static void internal_screenToWindowPos(ScriptEditorWindow* thisPtr, Vector2I screenPos, Vector2I* windowPos);
 		static void internal_screenToWindowPos(ScriptEditorWindow* thisPtr, Vector2I screenPos, Vector2I* windowPos);

+ 14 - 0
SBansheeEditor/Source/BsScriptEditorWindow.cpp

@@ -44,6 +44,7 @@ namespace BansheeEngine
 	void ScriptEditorWindow::initRuntimeData()
 	void ScriptEditorWindow::initRuntimeData()
 	{
 	{
 		metaData.scriptClass->addInternalCall("Internal_CreateOrGetInstance", &ScriptEditorWindow::internal_createOrGetInstance);
 		metaData.scriptClass->addInternalCall("Internal_CreateOrGetInstance", &ScriptEditorWindow::internal_createOrGetInstance);
+		metaData.scriptClass->addInternalCall("Internal_GetInstance", &ScriptEditorWindow::internal_getInstance);
 		metaData.scriptClass->addInternalCall("Internal_GetWidth", &ScriptEditorWindow::internal_getWidth);
 		metaData.scriptClass->addInternalCall("Internal_GetWidth", &ScriptEditorWindow::internal_getWidth);
 		metaData.scriptClass->addInternalCall("Internal_GetHeight", &ScriptEditorWindow::internal_getHeight);
 		metaData.scriptClass->addInternalCall("Internal_GetHeight", &ScriptEditorWindow::internal_getHeight);
 		metaData.scriptClass->addInternalCall("Internal_HasFocus", &ScriptEditorWindow::internal_hasFocus);
 		metaData.scriptClass->addInternalCall("Internal_HasFocus", &ScriptEditorWindow::internal_hasFocus);
@@ -75,6 +76,19 @@ namespace BansheeEngine
 		return nullptr;
 		return nullptr;
 	}
 	}
 
 
+	MonoObject* ScriptEditorWindow::internal_getInstance(MonoString* ns, MonoString* typeName)
+	{
+		String strTypeName = toString(MonoUtil::monoToWString(typeName));
+		String strNamespace = toString(MonoUtil::monoToWString(ns));
+		String fullName = strNamespace + "." + strTypeName;
+
+		auto findIter = OpenScriptEditorWindows.find(fullName);
+		if (findIter != OpenScriptEditorWindows.end())
+			return findIter->second.nativeObj->mManagedInstance;
+
+		return nullptr;
+	}
+
 	EditorWidgetBase* ScriptEditorWindow::getEditorWidget() const 
 	EditorWidgetBase* ScriptEditorWindow::getEditorWidget() const 
 	{ 
 	{ 
 		return mEditorWidget; 
 		return mEditorWidget; 

+ 5 - 4
TODO.txt

@@ -56,20 +56,21 @@ Code quality improvements:
 ----------------------------------------------------------------------
 ----------------------------------------------------------------------
 Polish stage 1
 Polish stage 1
 
 
-Fix DX11 (and possibly DX9) rendering
-Main window resize areas don't seem to be set up or work
 After undocking ProjectWindow the auto-scroll seems to be stuck in up position
 After undocking ProjectWindow the auto-scroll seems to be stuck in up position
-Decent looking default layout
 When selecting an gizmo icon the selection seems delayed and its gizmos flash for a frame before hiding (Can't reproduce atm but I saw it)
 When selecting an gizmo icon the selection seems delayed and its gizmos flash for a frame before hiding (Can't reproduce atm but I saw it)
+Main window resize areas don't seem to be set up or work
 Make proper window names instead of InspectorWindow
 Make proper window names instead of InspectorWindow
+Decent looking default layout
 
 
 Fix handles
 Fix handles
  - Some handle functionality is unfinished
  - Some handle functionality is unfinished
  - Handles look too large when scene view is enlarged
  - Handles look too large when scene view is enlarged
  - Moving around XZ plane seems to be wrong (it doesn't move as fast as the mouse)
  - Moving around XZ plane seems to be wrong (it doesn't move as fast as the mouse)
+ - Handle (and gizmo) shaders suck
 
 
-Add ping to SceneTreeView
+SceneTreeView
  - Hook up ping effect so it triggers when I select a resource or sceneobject
  - Hook up ping effect so it triggers when I select a resource or sceneobject
+ - See if it needs other enhancements (rename, delete all work properly? etc.)
 
 
 Finish up inspector
 Finish up inspector
  - Do I handle the case of updating the inspector when component is added or removed?
  - Do I handle the case of updating the inspector when component is added or removed?