|
|
@@ -24,6 +24,11 @@ uint nodeContainerIndex = M_MAX_UNSIGNED;
|
|
|
uint componentContainerStartIndex = 0;
|
|
|
uint elementContainerIndex = M_MAX_UNSIGNED;
|
|
|
|
|
|
+// Script Attribute session storage
|
|
|
+VariantMap scriptAttributes;
|
|
|
+const uint SCRIPTINSTANCE_ATTRIBUTE_IGNORE = 5;
|
|
|
+const uint LUASCRIPTINSTANCE_ATTRIBUTE_IGNORE = 4;
|
|
|
+
|
|
|
void InitXMLResources()
|
|
|
{
|
|
|
String[] resources = { "UI/EditorInspector_Attribute.xml", "UI/EditorInspector_Variable.xml", "UI/EditorInspector_Style.xml" };
|
|
|
@@ -253,7 +258,14 @@ void UpdateAttributeInspector(bool fullUpdate = true)
|
|
|
|
|
|
Array<Serializable@> components;
|
|
|
for (uint i = 0; i < numEditableComponents; ++i)
|
|
|
- components.Push(editComponents[j * numEditableComponents + i]);
|
|
|
+ {
|
|
|
+ Component@ component = editComponents[j * numEditableComponents + i];
|
|
|
+
|
|
|
+ if (component.typeName.Contains("ScriptInstance"))
|
|
|
+ UpdateScriptAttributes(component);
|
|
|
+
|
|
|
+ components.Push(component);
|
|
|
+ }
|
|
|
|
|
|
UpdateAttributes(components, container.GetChild("AttributeList"), fullUpdate);
|
|
|
SetAttributeEditorID(container.GetChild("ResetToDefault", true), components);
|
|
|
@@ -320,6 +332,49 @@ void UpdateAttributeInspector(bool fullUpdate = true)
|
|
|
HandleWindowLayoutUpdated();
|
|
|
}
|
|
|
|
|
|
+String GetComponentAttributeHash(Component@ component, uint index)
|
|
|
+{
|
|
|
+ // We won't consider the main attributes, as they won't reset when an error occurs.
|
|
|
+ if (component.typeName == "ScriptInstance")
|
|
|
+ {
|
|
|
+ if (index <= SCRIPTINSTANCE_ATTRIBUTE_IGNORE)
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (index <= LUASCRIPTINSTANCE_ATTRIBUTE_IGNORE)
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ AttributeInfo attributeInfo = component.attributeInfos[index];
|
|
|
+ Variant attribute = component.attributes[index];
|
|
|
+ return String(component.id) + "-" + attributeInfo.name + "-" + attribute.typeName;
|
|
|
+}
|
|
|
+
|
|
|
+void UpdateScriptAttributes(Component@ component)
|
|
|
+{
|
|
|
+ for (uint i = Min(SCRIPTINSTANCE_ATTRIBUTE_IGNORE, LUASCRIPTINSTANCE_ATTRIBUTE_IGNORE) + 1; i < component.numAttributes; i++)
|
|
|
+ {
|
|
|
+ Variant attribute = component.attributes[i];
|
|
|
+ // Component/node ID's are always unique within a scene, based on a simple increment.
|
|
|
+ // This makes for a simple method of mapping a components attributes unique and consistent.
|
|
|
+ // We will also use the type name in the hash to be able to recall and differentiate type changes.
|
|
|
+ String hash = GetComponentAttributeHash(component, i);
|
|
|
+ if (hash.empty)
|
|
|
+ continue;
|
|
|
+
|
|
|
+ if (!scriptAttributes.Contains(hash))
|
|
|
+ {
|
|
|
+ // set the initial value to the default value.
|
|
|
+ scriptAttributes[hash] = attribute;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // recall the previously stored value
|
|
|
+ component.attributes[i] = scriptAttributes[hash];
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
/// Update the attribute list of the node container.
|
|
|
void UpdateNodeAttributes()
|
|
|
{
|