Browse Source

ProjectLibrary::create added and working

Marko Pintera 11 years ago
parent
commit
4ee72a455c

+ 5 - 1
BansheeEditor/Source/BsGUIResourceTreeView.cpp

@@ -215,7 +215,7 @@ namespace BansheeEngine
 			else
 				curElem = relPath[idx];
 
-			current = nullptr;
+			bool foundChild = false;
 			for (auto& child : current->mChildren)
 			{
 				ResourceTreeElement* resourceChild = static_cast<ResourceTreeElement*>(child);
@@ -223,9 +223,13 @@ namespace BansheeEngine
 				{
 					idx++;
 					current = resourceChild;
+					foundChild = true;
 					break;
 				}
 			}
+
+			if (!foundChild)
+				current = nullptr;
 		}
 
 		return nullptr;

+ 3 - 1
BansheeEditor/Source/BsProjectLibrary.cpp

@@ -446,12 +446,12 @@ namespace BansheeEngine
 			else
 				curElem = relPath[idx];
 
-			current = nullptr;
 			if (current->type == LibraryEntryType::Directory)
 			{
 				DirectoryEntry* dirEntry = static_cast<DirectoryEntry*>(current);
 				for (auto& child : dirEntry->mChildren)
 				{
+					current = nullptr;
 					if (Path::comparePathElem(curElem, child->elementName))
 					{
 						idx++;
@@ -460,6 +460,8 @@ namespace BansheeEngine
 					}
 				}
 			}
+			else
+				break;
 		}
 
 		return nullptr;

+ 0 - 2
BansheeMono/Source/BsMonoAssembly.cpp

@@ -126,8 +126,6 @@ namespace BansheeEngine
 		if(!mIsLoaded)
 			BS_EXCEPT(InvalidStateException, "Trying to use an unloaded assembly.");
 
-
-
 		MonoAssembly::ClassId classId(namespaceName, name);
 		auto iterFind = mClasses.find(classId);
 

+ 1 - 1
BansheeUtility/Source/BsPath.cpp

@@ -291,7 +291,7 @@ namespace BansheeEngine
 				return false;
 		}
 
-		if (mFilename != child.mFilename)
+		if (isFile() && mFilename != child.mFilename)
 			return false;
 
 		return true;

+ 3 - 6
Inspector.txt

@@ -1,12 +1,9 @@
 Update C# GUIElementStyle
 Update GUIFoldout with sub styles
 
-Finish ProjectLibrary::create
- - Resource gets serialized directly as .asset (whether its a mesh, texture or custom asset)
- - When ProjectLibrary encounters such resource it will import it using a dummy pass through importer
-
-Need to add stuff derived from ManagedResource to serializable list in RuntimeScriptObjects
-
+Test custom resources:
+ - Can I load them? (Will likely need ProjectLIbrary::load)
+ - Can I reference them in Component and will the reference be held after after cloning?
 
 TODO:
  - Hook up int field set/get callbacks

+ 5 - 1
MBansheeEditor/DbgResource.cs

@@ -3,10 +3,14 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using BansheeEngine;
 
 namespace BansheeEditor
 {
-    class DbgResource
+    public class DbgResource : ManagedResource
     {
+        public int some;
+        public string test;
+        public float data;
     }
 }

+ 2 - 1
MBansheeEditor/Program.cs

@@ -17,7 +17,8 @@ namespace BansheeEditor
             window.SetObjectToInspect(newDbgObject);
             window.Refresh(); // TODO - This should be called N times per second
 
-
+            DbgResource testResource = new DbgResource();
+            ProjectLibrary.Create(testResource, @"D:\DummyBansheeProject\Resources\testResource");
 
 
 

+ 2 - 2
MBansheeEngine/ManagedResource.cs

@@ -10,10 +10,10 @@ namespace BansheeEngine
     {
         public ManagedResource()
         {
-            Internal_CreateResource(this);
+            Internal_CreateInstance(this);
         }
 
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_CreateResource(ManagedResource resource);
+        private static extern void Internal_CreateInstance(ManagedResource resource);
     }
 }

+ 1 - 1
SBansheeEngine/Include/BsManagedResourceRTTI.h

@@ -35,7 +35,7 @@ namespace BansheeEngine
 			mc->mRTTIData = ManagedSerializableObject::create(mc->getManagedInstance());
 		}
 
-		virtual void onDeserializationStarted(IReflectable* obj)
+		virtual void onDeserializationEnded(IReflectable* obj)
 		{
 			ManagedResource* mc = static_cast<ManagedResource*>(obj);
 			ManagedSerializableObjectPtr serializableObject = any_cast<ManagedSerializableObjectPtr>(mc->mRTTIData);

+ 15 - 3
SBansheeEngine/Include/BsManagedSerializableObjectRTTI.h

@@ -60,12 +60,24 @@ namespace BansheeEngine
 		virtual void onDeserializationStarted(IReflectable* obj)
 		{
 			ManagedSerializableObject* serializableObject = static_cast<ManagedSerializableObject*>(obj);
-
+			
 			// If we are deserializing a GameObject we need to defer deserializing actual field values
 			// to ensure GameObject handles instances have been fixed up (which only happens after deserialization is done)
-			if(GameObjectManager::instance().isGameObjectDeserializationActive())
-				GameObjectManager::instance().registerOnDeserializationEndCallback([=] () { serializableObject->deserializeManagedInstance(); });
+			if (GameObjectManager::instance().isGameObjectDeserializationActive())
+			{
+				GameObjectManager::instance().registerOnDeserializationEndCallback([=]() { serializableObject->deserializeManagedInstance(); });
+				serializableObject->mRTTIData = true;
+			}
 			else
+				serializableObject->mRTTIData = false;
+		}
+
+		virtual void onDeserializationEnded(IReflectable* obj)
+		{
+			ManagedSerializableObject* serializableObject = static_cast<ManagedSerializableObject*>(obj);
+
+			bool isGameObjectDeserialization = any_cast<bool>(serializableObject->mRTTIData);
+			if (!isGameObjectDeserialization)
 				serializableObject->deserializeManagedInstance();
 		}