Просмотр исходного кода

Fixed an issue where dragging a prefab/mesh over scene view, even if another window is on top of it, will trigger the prefab/mesh to instantiate
Fixed a bug where refusing to save the scene before build would terminate the editor

BearishSun 10 лет назад
Родитель
Сommit
1aa41e445c

+ 2 - 1
BansheeEditor/Include/BsEditorWidget.h

@@ -78,7 +78,8 @@ namespace BansheeEngine
 		bool isActive() const { return mIsActive; }
 		bool isActive() const { return mIsActive; }
 
 
 		/**
 		/**
-		 * @brief	Gets the parent editor window this widget is docked in.
+		 * @brief	Gets the parent editor window this widget is docked in. Can be null (e.g. when widget is in the
+		 *			process of dragging and not visible).
 		 */
 		 */
 		EditorWindowBase* getParentWindow() const;
 		EditorWindowBase* getParentWindow() const;
 
 

+ 1 - 4
MBansheeEditor/BuildWindow.cs

@@ -259,10 +259,7 @@ namespace BansheeEditor
                 if (result == DialogBox.ResultType.Yes)
                 if (result == DialogBox.ResultType.Yes)
                     TrySaveScene();
                     TrySaveScene();
                 else if (result == DialogBox.ResultType.No)
                 else if (result == DialogBox.ResultType.No)
-                {
-                    EditorApplication.SaveProject();
-                    EditorApplication.Quit();
-                }
+                    Build();
             };
             };
 
 
             if (EditorApplication.IsSceneModified())
             if (EditorApplication.IsSceneModified())

+ 8 - 0
MBansheeEditor/EditorWindow.cs

@@ -45,6 +45,11 @@ namespace BansheeEditor
         /// </summary>
         /// </summary>
         public bool HasFocus { get { return Internal_HasFocus(mCachedPtr); } }
         public bool HasFocus { get { return Internal_HasFocus(mCachedPtr); } }
 
 
+        /// <summary>
+        /// Determines is the mouse pointer currently hovering over the editor window.
+        /// </summary>
+        public bool IsPointerHovering { get { return Internal_IsPointerHovering(mCachedPtr); } }
+
         /// <summary>
         /// <summary>
         /// Checks if the window's tab is currently active. If the window is floating or not sharing space with any other
         /// Checks if the window's tab is currently active. If the window is floating or not sharing space with any other
         /// windows (just a single tab), it is always considered active.
         /// windows (just a single tab), it is always considered active.
@@ -143,6 +148,9 @@ namespace BansheeEditor
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern bool Internal_IsActive(IntPtr nativeInstance);
         private static extern bool Internal_IsActive(IntPtr nativeInstance);
 
 
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern bool Internal_IsPointerHovering(IntPtr nativeInstance);
+
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern void Internal_GetBounds(IntPtr nativeInstance, out Rect2I bounds);
         private static extern void Internal_GetBounds(IntPtr nativeInstance, out Rect2I bounds);
 
 

+ 1 - 1
MBansheeEditor/Scene/SceneWindow.cs

@@ -445,7 +445,7 @@ namespace BansheeEditor
             bool inBounds = ScreenToScenePos(Input.PointerPosition, out scenePos);
             bool inBounds = ScreenToScenePos(Input.PointerPosition, out scenePos);
 
 
             bool draggedOver = DragDrop.DragInProgress || DragDrop.DropInProgress;
             bool draggedOver = DragDrop.DragInProgress || DragDrop.DropInProgress;
-            draggedOver &= inBounds && DragDrop.Type == DragDropType.Resource;
+            draggedOver &= IsPointerHovering && inBounds && DragDrop.Type == DragDropType.Resource;
 
 
             if (draggedOver)
             if (draggedOver)
             {
             {

+ 1 - 0
SBansheeEditor/Include/BsScriptEditorWindow.h

@@ -133,6 +133,7 @@ namespace BansheeEngine
 
 
 		static bool internal_hasFocus(ScriptEditorWindow* thisPtr);
 		static bool internal_hasFocus(ScriptEditorWindow* thisPtr);
 		static bool internal_isActive(ScriptEditorWindow* thisPtr);
 		static bool internal_isActive(ScriptEditorWindow* thisPtr);
+		static bool internal_isPointerHovering(ScriptEditorWindow* thisPtr);
 		static void internal_screenToWindowPos(ScriptEditorWindow* thisPtr, Vector2I* screenPos, Vector2I* windowPos);
 		static void internal_screenToWindowPos(ScriptEditorWindow* thisPtr, Vector2I* screenPos, Vector2I* windowPos);
 		static void internal_windowToScreenPos(ScriptEditorWindow* thisPtr, Vector2I* windowPos, Vector2I* screenPos);
 		static void internal_windowToScreenPos(ScriptEditorWindow* thisPtr, Vector2I* windowPos, Vector2I* screenPos);
 		static UINT32 internal_getWidth(ScriptEditorWindow* thisPtr);
 		static UINT32 internal_getWidth(ScriptEditorWindow* thisPtr);

+ 32 - 0
SBansheeEditor/Source/BsScriptEditorWindow.cpp

@@ -13,6 +13,8 @@
 #include "BsScriptObjectManager.h"
 #include "BsScriptObjectManager.h"
 #include "BsScriptGUILayout.h"
 #include "BsScriptGUILayout.h"
 #include "BsScriptHString.h"
 #include "BsScriptHString.h"
+#include "BsPlatform.h"
+#include "BsInput.h"
 
 
 using namespace std::placeholders;
 using namespace std::placeholders;
 
 
@@ -52,6 +54,7 @@ namespace BansheeEngine
 		metaData.scriptClass->addInternalCall("Internal_GetBounds", &ScriptEditorWindow::internal_getBounds);
 		metaData.scriptClass->addInternalCall("Internal_GetBounds", &ScriptEditorWindow::internal_getBounds);
 		metaData.scriptClass->addInternalCall("Internal_HasFocus", &ScriptEditorWindow::internal_hasFocus);
 		metaData.scriptClass->addInternalCall("Internal_HasFocus", &ScriptEditorWindow::internal_hasFocus);
 		metaData.scriptClass->addInternalCall("Internal_IsActive", &ScriptEditorWindow::internal_isActive);
 		metaData.scriptClass->addInternalCall("Internal_IsActive", &ScriptEditorWindow::internal_isActive);
+		metaData.scriptClass->addInternalCall("Internal_IsPointerHovering", &ScriptEditorWindow::internal_isPointerHovering);
 		metaData.scriptClass->addInternalCall("Internal_ScreenToWindowPos", &ScriptEditorWindow::internal_screenToWindowPos);
 		metaData.scriptClass->addInternalCall("Internal_ScreenToWindowPos", &ScriptEditorWindow::internal_screenToWindowPos);
 		metaData.scriptClass->addInternalCall("Internal_WindowToScreenPos", &ScriptEditorWindow::internal_windowToScreenPos);
 		metaData.scriptClass->addInternalCall("Internal_WindowToScreenPos", &ScriptEditorWindow::internal_windowToScreenPos);
 
 
@@ -180,6 +183,35 @@ namespace BansheeEngine
 			return false;
 			return false;
 	}
 	}
 
 
+	bool ScriptEditorWindow::internal_isPointerHovering(ScriptEditorWindow* thisPtr)
+	{
+		if (!thisPtr->isDestroyed())
+		{
+			EditorWidgetBase* widget = thisPtr->getEditorWidget();
+			EditorWindowBase* window = widget->getParentWindow();
+			if (window == nullptr)
+				return false;
+
+			RenderWindowPtr renderWindow = window->getRenderWindow();
+
+			Vector2I pointerPos = gInput().getPointerPosition();
+			if(Platform::isPointOverWindow(*renderWindow, pointerPos))
+			{
+				Rect2I bounds = thisPtr->getEditorWidget()->getBounds();
+
+				Vector2I widgetPos(bounds.x, bounds.y);
+				Vector2I screenPos = widget->widgetToScreenPos(widgetPos);
+
+				bounds.x = screenPos.x;
+				bounds.y = screenPos.y;
+
+				return bounds.contains(pointerPos);
+			}
+		}
+
+		return false;
+	}
+
 	void ScriptEditorWindow::internal_screenToWindowPos(ScriptEditorWindow* thisPtr, Vector2I* screenPos, Vector2I* windowPos)
 	void ScriptEditorWindow::internal_screenToWindowPos(ScriptEditorWindow* thisPtr, Vector2I* screenPos, Vector2I* windowPos)
 	{
 	{
 		if (!thisPtr->isDestroyed())
 		if (!thisPtr->isDestroyed())