Browse Source

Managed serializable list resize works
Fixed an issue where array and list inspectables were adding element buttons whenever any child of the array/list was modified

Marko Pintera 10 years ago
parent
commit
1342e920d2

+ 1 - 1
MBansheeEditor/Inspector/InspectableArray.cs

@@ -24,7 +24,7 @@ namespace BansheeEditor
 
             public void Refresh(InspectableObjectBase child, int seqIndex, InspectableArray parent)
             {
-                if (ownsTitleLayout)
+                if (ownsTitleLayout || (titleLayout != null && titleLayout == child.GetTitleLayout()))
                     return;
 
                 titleLayout = child.GetTitleLayout();

+ 2 - 1
MBansheeEditor/Inspector/InspectableList.cs

@@ -24,7 +24,7 @@ namespace BansheeEditor
 
             public void Refresh(InspectableObjectBase child, int seqIndex, InspectableList parent)
             {
-                if (ownsTitleLayout)
+                if (ownsTitleLayout || (titleLayout != null && titleLayout == child.GetTitleLayout()))
                     return;
 
                 titleLayout = child.GetTitleLayout();
@@ -224,6 +224,7 @@ namespace BansheeEditor
 
             int maxSize = MathEx.Min(size, list.Count);
 
+            Debug.Log("List resize: " + list.Count + " - " + newList.Count + " - " + size);
             for (int i = 0; i < maxSize; i++)
                 newList[i] = list[i];
 

+ 10 - 2
SBansheeEngine/Source/BsManagedSerializableList.cpp

@@ -63,7 +63,15 @@ namespace BansheeEngine
 			return nullptr;
 
 		void* params[1] = { &size };
-		return listClass->createInstance("int", params);
+		MonoObject* instance = listClass->createInstance("int", params);
+		
+		ScriptArray tempArray(typeInfo->mElementType->getMonoClass(), size);
+		params[0] = tempArray.getInternal();
+
+		MonoMethod* addRangeMethod = listClass->getMethod("AddRange", 1);
+		addRangeMethod->invoke(instance, params);
+
+		return instance;
 	}
 
 	ManagedSerializableListPtr ManagedSerializableList::createEmpty()
@@ -165,7 +173,7 @@ namespace BansheeEngine
 		UINT32 idx = 0;
 		for (auto& entry : mCachedEntries)
 		{
-			addFieldDataInternal(entry);
+			setFieldData(idx, entry);
 			idx++;
 		}
 

+ 5 - 0
TODO.txt

@@ -54,6 +54,10 @@ Code quality improvements:
 ----------------------------------------------------------------------
 Polish
 
+TODO:
+ - Thoroughly test inspector
+ - Modifying structs doesn't persist changes
+
 Ribek use:
  - Camera, Renderable, Material, Texture inspector
   - Material/Shader has no color type so I cannot know when to display normal vector and when color in inspector
@@ -107,6 +111,7 @@ Other polish:
  - When I expand inspector elements and them come back to that object it should remember the previous state
    - Add a chaching mechanism to inspector (likely based on instance ID & property names)
    - This has to work not only when I come back to the object, but whenever inspector rebuilds (e.g. after removing element from array)
+   - Consider saving this information with the serialized object
  - Make sure to persist EditorSettings
  - Import option inspectors for Texture, Mesh, Font
  - DOck manager maximize doesn't work'