Bläddra i källkod

Applied the UI-element child sorting fix recursively.

Wei Tjong Yao 12 år sedan
förälder
incheckning
0af8f6afda
1 ändrade filer med 13 tillägg och 3 borttagningar
  1. 13 3
      Bin/Data/Scripts/Editor/EditorUIElement.as

+ 13 - 3
Bin/Data/Scripts/Editor/EditorUIElement.as

@@ -57,7 +57,7 @@ bool NewUIElement(const String&in typeName)
         }
         // Use the predefined UI style if set, otherwise use editor's own UI style
         element.style = uiElementDefaultStyle !is null ? uiElementDefaultStyle : uiStyle;
-        // Does not allow UI subsystem to reorder children while editing the element in the editor
+        // Do not allow UI subsystem to reorder children while editing the element in the editor
         element.sortChildren = false;
 
         // Create an undo action for the create
@@ -70,6 +70,15 @@ bool NewUIElement(const String&in typeName)
     return true;
 }
 
+void ResetSortChildren(UIElement@ element)
+{
+    element.sortChildren = false;
+
+    // Perform the action recursively for child elements
+    for (uint i = 0; i < element.numChildren; ++i)
+        ResetSortChildren(element.children[i]);
+}
+
 void OpenUIElement(const String&in fileName)
 {
     if (fileName.empty)
@@ -110,8 +119,8 @@ void OpenUIElement(const String&in fileName)
         element.vars[FILENAME_VAR] = fileName;
         element.vars[MODIFIED_VAR] = false;
 
-        // Does not allow UI subsystem to reorder children while editing the element in the editor
-        element.sortChildren = false;
+        // Do not allow UI subsystem to reorder children while editing the element in the editor
+        ResetSortChildren(element);
 
         editorUIElement.AddChild(element);
 
@@ -240,6 +249,7 @@ void LoadChildUIElement(const String&in fileName)
     if (editUIElement.LoadXML(xmlFile, uiElementDefaultStyle !is null ? uiElementDefaultStyle : uiStyle))
     {
         UIElement@ element = editUIElement.children[editUIElement.numChildren - 1];
+        ResetSortChildren(element);
         UpdateHierarchyItem(element);
 
         // Create an undo action for the load