Browse Source

Added support for enum serialization
Various fixes for assembly refresh (still WIP)

Marko Pintera 11 years ago
parent
commit
9d7c42430e

+ 11 - 1
MBansheeEngine/Camera.cs

@@ -11,7 +11,7 @@ namespace BansheeEngine
         private CameraHandler handler;
 
         [SerializeField]
-        private SerializableData serializableData;
+        private SerializableData serializableData = new SerializableData();
 
         internal CameraHandler Handler
         {
@@ -157,6 +157,16 @@ namespace BansheeEngine
         public Vector3 ProjectPoint(Vector3 value) { return handler.ProjectPoint(value); }
         public Vector3 UnprojectPoint(Vector3 value) { return handler.UnprojectPoint(value); }
 
+        private void OnInitialize()
+        {
+            serializableData.aspectRatio = 1.333f;
+            serializableData.nearClipPlane = 1.0f;
+            serializableData.farClipPlane = 1000.0f;
+            serializableData.fieldOfView = new Degree(60);
+            serializableData.viewportRect = new Rect2(0, 0, 1, 1);
+            serializableData.projectionType = ProjectionType.Perspective;
+        }
+
         private void OnReset()
         {
             handler = new CameraHandler(sceneObject);

+ 2 - 4
SBansheeEditor/Source/BsEditorScriptManager.cpp

@@ -20,8 +20,7 @@ namespace BansheeEngine
 	{
 		const String ASSEMBLY_ENTRY_POINT = "Program::Start";
 
-		ScriptEditorWindow::registerManagedEditorWindows();
-
+		loadMonoTypes();
 		ScriptAssemblyManager::instance().loadAssemblyInfo(BansheeEditorAssemblyName);
 
 		ScriptHandleSliderManager::startUp();
@@ -29,8 +28,7 @@ namespace BansheeEngine
 		HandleManager::startUp<ScriptHandleManager>(ScriptAssemblyManager::instance());
 
 		mOnDomainLoadConn = MonoManager::instance().onDomainReload.connect(std::bind(&EditorScriptManager::loadMonoTypes, this));
-		loadMonoTypes();
-
+		
 		mEditorAssembly->invoke(ASSEMBLY_ENTRY_POINT);
 
 		// Initial update

+ 1 - 1
SBansheeEditor/Source/BsScriptEditorWindow.cpp

@@ -282,7 +282,7 @@ namespace BansheeEngine
 
 	ScriptEditorWidget::ScriptEditorWidget(const String& ns, const String& type, EditorWidgetContainer& parentContainer)
 		:EditorWidgetBase(HString(toWString(type)), ns + "." + type, parentContainer), mNamespace(ns), mTypename(type),
-		mUpdateThunk(nullptr), mManagedInstance(nullptr)
+		mUpdateThunk(nullptr), mManagedInstance(nullptr), mOnInitializeInternalThunk(nullptr), mOnInitializeThunk(nullptr)
 	{
 		createManagedInstance();
 	}

+ 8 - 0
SBansheeEngine/Source/BsScriptAssemblyManager.cpp

@@ -174,6 +174,14 @@ namespace BansheeEngine
 		MonoType* monoType = mono_class_get_type(monoClass->_getInternalClass());
 		int monoPrimitiveType = mono_type_get_type(monoType);
 		
+		// If enum get the enum base data type
+		bool isEnum = mono_class_is_enum(monoClass->_getInternalClass());
+		if (isEnum)
+		{
+			MonoType* underlyingType = mono_type_get_underlying_type(monoType);
+			monoPrimitiveType = mono_type_get_type(underlyingType);
+		}
+
 		//  Determine field type
 		switch(monoPrimitiveType)
 		{

+ 1 - 0
SBansheeEngine/Source/BsScriptEnginePlugin.cpp

@@ -14,6 +14,7 @@
 #include "BsScriptSceneObject.h"
 #include "BsSceneObject.h"
 #include "BsMonoUtil.h"
+#include "BsMonoMethod.h"
 
 namespace BansheeEngine
 {

+ 9 - 0
TODO.txt

@@ -9,6 +9,15 @@ Enum serialization probably doesn't work. I'll need to fix that before serializi
 
 When component type cannot be found upon refresh it will still remain on SceneObject, invisible. Make sure it is not saved as such, or make it visible and removable.
 
+Add support for multiple components of the same type
+  - This can be changed on per-component basis
+  - How does that even work with ManagedComponent right now?
+  - Add "MissingComponent" ManagedComponent 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
+   - 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>>>>:
  - Modify Font so it doesn't contain a texture, but instead keeps a handle to it
  - Register it in its meta file