Răsfoiți Sursa

More fixes due to assembly refresh changes - Editor runs

Marko Pintera 11 ani în urmă
părinte
comite
1f8b1397d7

+ 3 - 0
BansheeEditor/Source/BsEditorWidgetManager.cpp

@@ -273,6 +273,9 @@ namespace BansheeEngine
 		{
 		{
 			EditorWidgetBase* widget = widgetData.second;
 			EditorWidgetBase* widget = widgetData.second;
 			EditorWidgetContainer* parentContainer = widget->_getParent();
 			EditorWidgetContainer* parentContainer = widget->_getParent();
+			if (parentContainer == nullptr)
+				continue;
+
 			EditorWindowBase* parentWindow = parentContainer->getParentWindow();
 			EditorWindowBase* parentWindow = parentContainer->getParentWindow();
 			RenderWindowPtr parentRenderWindow = parentWindow->_getRenderWindow();
 			RenderWindowPtr parentRenderWindow = parentWindow->_getRenderWindow();
 
 

+ 4 - 0
BansheeUtility/Source/BsDebug.cpp

@@ -8,11 +8,15 @@
 
 
 #if BS_PLATFORM == BS_PLATFORM_WIN32 && BS_COMPILER == BS_COMPILER_MSVC
 #if BS_PLATFORM == BS_PLATFORM_WIN32 && BS_COMPILER == BS_COMPILER_MSVC
 #include <windows.h>
 #include <windows.h>
+#include <iostream>
 
 
 void logToIDEConsole(const BansheeEngine::String& message)
 void logToIDEConsole(const BansheeEngine::String& message)
 {
 {
 	OutputDebugString(message.c_str());
 	OutputDebugString(message.c_str());
 	OutputDebugString("\n");
 	OutputDebugString("\n");
+
+	// Also default output in case we're running without debugger attached
+	std::cout << message << std::endl;
 }
 }
 #else
 #else
 void logToIDEConsole(const BansheeEngine::String& message)
 void logToIDEConsole(const BansheeEngine::String& message)

+ 13 - 13
MBansheeEngine/Camera.cs

@@ -172,19 +172,19 @@ namespace BansheeEngine
             handler = new CameraHandler(sceneObject);
             handler = new CameraHandler(sceneObject);
 
 
             // Restore saved values after reset
             // Restore saved values after reset
-            handler.aspectRatio = serializableData.aspectRatio;
-            handler.nearClipPlane = serializableData.nearClipPlane;
-            handler.farClipPlane = serializableData.farClipPlane;
-            handler.fieldOfView = serializableData.fieldOfView;
-            handler.viewportRect = serializableData.viewportRect;
-            handler.projectionType = serializableData.projectionType;
-            handler.orthoHeight = serializableData.orthoHeight;
-            handler.clearColor = serializableData.clearColor;
-            handler.clearDepth = serializableData.clearDepth;
-            handler.clearStencil = serializableData.clearStencil;
-            handler.clearFlags = serializableData.clearFlags;
-            handler.priority = serializableData.priority;
-            handler.layers = serializableData.layers;
+            //handler.aspectRatio = serializableData.aspectRatio;
+            //handler.nearClipPlane = serializableData.nearClipPlane;
+            //handler.farClipPlane = serializableData.farClipPlane;
+            //handler.fieldOfView = serializableData.fieldOfView;
+            //handler.viewportRect = serializableData.viewportRect;
+            //handler.projectionType = serializableData.projectionType;
+            //handler.orthoHeight = serializableData.orthoHeight;
+            //handler.clearColor = serializableData.clearColor;
+            //handler.clearDepth = serializableData.clearDepth;
+            //handler.clearStencil = serializableData.clearStencil;
+            //handler.clearFlags = serializableData.clearFlags;
+            //handler.priority = serializableData.priority;
+            //handler.layers = serializableData.layers;
 
 
             // TODO - Make RenderTexture a resource so I can save/restore it?
             // TODO - Make RenderTexture a resource so I can save/restore it?
         }
         }

+ 2 - 1
SBansheeEditor/Include/BsScriptEditorWindow.h

@@ -25,6 +25,7 @@ namespace BansheeEngine
 
 
 		static void registerManagedEditorWindows();
 		static void registerManagedEditorWindows();
 		static void clearRegisteredEditorWindow();
 		static void clearRegisteredEditorWindow();
+
 	private:
 	private:
 		friend class ScriptEditorWidget;
 		friend class ScriptEditorWidget;
 
 
@@ -61,6 +62,7 @@ namespace BansheeEngine
 
 
 		static MonoMethod* onResizedMethod;
 		static MonoMethod* onResizedMethod;
 		static MonoMethod* onFocusChangedMethod;
 		static MonoMethod* onFocusChangedMethod;
+		static MonoMethod* onInitializedInternalMethod;
 
 
 		// Global editor window management methods
 		// Global editor window management methods
 		static void registerScriptEditorWindow(ScriptEditorWindow* editorWindow);
 		static void registerScriptEditorWindow(ScriptEditorWindow* editorWindow);
@@ -93,7 +95,6 @@ namespace BansheeEngine
 		String mTypename;
 		String mTypename;
 
 
 		OnInitializeThunkDef mOnInitializeThunk;
 		OnInitializeThunkDef mOnInitializeThunk;
-		OnInitializeThunkDef mOnInitializeInternalThunk;
 		UpdateThunkDef mUpdateThunk;
 		UpdateThunkDef mUpdateThunk;
 		MonoObject* mManagedInstance;
 		MonoObject* mManagedInstance;
 
 

+ 5 - 13
SBansheeEditor/Source/BsScriptEditorWindow.cpp

@@ -19,6 +19,7 @@ namespace BansheeEngine
 	Vector<String> ScriptEditorWindow::AvailableWindowTypes;
 	Vector<String> ScriptEditorWindow::AvailableWindowTypes;
 	MonoMethod* ScriptEditorWindow::onResizedMethod = nullptr;
 	MonoMethod* ScriptEditorWindow::onResizedMethod = nullptr;
 	MonoMethod* ScriptEditorWindow::onFocusChangedMethod = nullptr;
 	MonoMethod* ScriptEditorWindow::onFocusChangedMethod = nullptr;
+	MonoMethod* ScriptEditorWindow::onInitializedInternalMethod = nullptr;
 
 
 	ScriptEditorWindow::ScriptEditorWindow(ScriptEditorWidget* editorWidget)
 	ScriptEditorWindow::ScriptEditorWindow(ScriptEditorWidget* editorWidget)
 		:ScriptObject(editorWidget->getManagedInstance()), mName(editorWidget->getName()), mEditorWidget(editorWidget), mRefreshInProgress(false)
 		:ScriptObject(editorWidget->getManagedInstance()), mName(editorWidget->getName()), mEditorWidget(editorWidget), mRefreshInProgress(false)
@@ -50,6 +51,7 @@ namespace BansheeEngine
 
 
 		onResizedMethod = metaData.scriptClass->getMethod("WindowResized", 2);
 		onResizedMethod = metaData.scriptClass->getMethod("WindowResized", 2);
 		onFocusChangedMethod = metaData.scriptClass->getMethod("FocusChanged", 1);
 		onFocusChangedMethod = metaData.scriptClass->getMethod("FocusChanged", 1);
+		onInitializedInternalMethod = metaData.scriptClass->getMethod("OnInitializeInternal", 0);
 	}
 	}
 
 
 	MonoObject* ScriptEditorWindow::internal_createOrGetInstance(MonoString* ns, MonoString* typeName)
 	MonoObject* ScriptEditorWindow::internal_createOrGetInstance(MonoString* ns, MonoString* typeName)
@@ -282,7 +284,7 @@ namespace BansheeEngine
 
 
 	ScriptEditorWidget::ScriptEditorWidget(const String& ns, const String& type, EditorWidgetContainer& parentContainer)
 	ScriptEditorWidget::ScriptEditorWidget(const String& ns, const String& type, EditorWidgetContainer& parentContainer)
 		:EditorWidgetBase(HString(toWString(type)), ns + "." + type, parentContainer), mNamespace(ns), mTypename(type),
 		:EditorWidgetBase(HString(toWString(type)), ns + "." + type, parentContainer), mNamespace(ns), mTypename(type),
-		mUpdateThunk(nullptr), mManagedInstance(nullptr), mOnInitializeInternalThunk(nullptr), mOnInitializeThunk(nullptr)
+		mUpdateThunk(nullptr), mManagedInstance(nullptr), mOnInitializeThunk(nullptr)
 	{
 	{
 		createManagedInstance();
 		createManagedInstance();
 	}
 	}
@@ -314,13 +316,8 @@ namespace BansheeEngine
 
 
 	void ScriptEditorWidget::triggerOnInitialize()
 	void ScriptEditorWidget::triggerOnInitialize()
 	{
 	{
-		if (mOnInitializeInternalThunk != nullptr && mManagedInstance != nullptr)
-		{
-			MonoException* exception = nullptr;
-			mOnInitializeInternalThunk(mManagedInstance, &exception);
-
-			MonoUtil::throwIfException(exception);
-		}
+		if (mManagedInstance != nullptr)
+			ScriptEditorWindow::onInitializedInternalMethod->invoke(mManagedInstance, nullptr);
 
 
 		if (mOnInitializeThunk != nullptr && mManagedInstance != nullptr)
 		if (mOnInitializeThunk != nullptr && mManagedInstance != nullptr)
 		{
 		{
@@ -359,10 +356,5 @@ namespace BansheeEngine
 
 
 		if (onInitializeMethod != nullptr)
 		if (onInitializeMethod != nullptr)
 			mOnInitializeThunk = (OnInitializeThunkDef)onInitializeMethod->getThunk();
 			mOnInitializeThunk = (OnInitializeThunkDef)onInitializeMethod->getThunk();
-
-		MonoMethod* onInitializeInternalMethod = windowClass->getMethod("OnInitializeInternal", 0);
-
-		if (onInitializeInternalMethod != nullptr)
-			mOnInitializeInternalThunk = (OnInitializeThunkDef)onInitializeInternalMethod->getThunk();
 	}
 	}
 }
 }

+ 1 - 1
SBansheeEngine/Source/BsScriptAssemblyManager.cpp

@@ -175,7 +175,7 @@ namespace BansheeEngine
 		int monoPrimitiveType = mono_type_get_type(monoType);
 		int monoPrimitiveType = mono_type_get_type(monoType);
 		
 		
 		// If enum get the enum base data type
 		// If enum get the enum base data type
-		bool isEnum = mono_class_is_enum(monoClass->_getInternalClass());
+		bool isEnum = mono_class_is_enum(monoClass->_getInternalClass()) == 1;
 		if (isEnum)
 		if (isEnum)
 		{
 		{
 			MonoType* underlyingType = mono_type_get_underlying_type(monoType);
 			MonoType* underlyingType = mono_type_get_underlying_type(monoType);

+ 2 - 2
TODO.txt

@@ -16,8 +16,6 @@ Add support for multiple components of the same type
    - Instantiate that once a specific component instance cannot be found, also save the backup data on that missing component in case it gets restored
    - Instantiate that once a specific component instance cannot be found, also save the backup data on that missing component in case it gets restored
    - Every assembly reload try to restore all missing components if possible
    - Every assembly reload try to restore all missing components if possible
 
 
-Get rid of thunks? I cannot receive exceptions from thunks apparently so a C# exception causes an access violation.
-
 <<<<Multi-resource saving>>>>:
 <<<<Multi-resource saving>>>>:
  - Modify Font so it doesn't contain a texture, but instead keeps a handle to it
  - Modify Font so it doesn't contain a texture, but instead keeps a handle to it
  - Register it in its meta file
  - Register it in its meta file
@@ -32,6 +30,8 @@ Add cutoff plane when rendering discs for rotation handle.
 I can get mono errors by checking g_print calls in goutput.c
 I can get mono errors by checking g_print calls in goutput.c
  - Calling thunks incorrectly can cause those weird errors with no real callstack
  - Calling thunks incorrectly can cause those weird errors with no real callstack
 
 
+Running embedded mono with VS attached causes managed null refs to be registered as access violations
+
 Crash on GLTextureBuffer::download on shutdown (OpenGL error invalid enum)
 Crash on GLTextureBuffer::download on shutdown (OpenGL error invalid enum)
 Create a stack allocatable custom vector implementation and make getResourceDependencies and getCoreDependencies use it
 Create a stack allocatable custom vector implementation and make getResourceDependencies and getCoreDependencies use it