Browse Source

Handle updating dynamic fields on undo/redo

Josh Engebretson 10 years ago
parent
commit
4faf110d10

+ 9 - 1
Script/AtomicEditor/ui/frames/inspector/AttributeInfoEdit.ts

@@ -395,7 +395,15 @@ class FloatAttributeEdit extends AttributeInfoEdit {
                 var widget = this.editWidget;
                 var attrInfo = this.attrInfo;
                 var value = object.getAttribute(attrInfo.name);
-                widget.text = parseFloat(value.toFixed(5)).toString();
+
+                if (value == undefined) {
+
+                  console.log("WARNING: Undefined value for object: ", this.editType.typeName + "." + attrInfo.name);
+                  widget.text = "???";
+
+                } else {
+                  widget.text = parseFloat(value.toFixed(5)).toString();
+                }
 
             }
 

+ 12 - 3
Script/AtomicEditor/ui/frames/inspector/SelectionInspector.ts

@@ -101,6 +101,8 @@ class JSComponentSection extends ComponentSection {
 
         super(editType, inspector);
 
+        this.hasDynamicAttr = true;
+
         this.subscribeToEvent(this, "AttributeEditResourceChanged", (ev) => this.handleAttributeEditResourceChanged(ev));
 
     }
@@ -113,11 +115,8 @@ class JSComponentSection extends ComponentSection {
             return;
 
         var attrInfos = jsc.getAttributes();
-
         this.updateDynamicAttrInfos(attrInfos);
 
-        //console.log("Resource Changed:", this.editType.typeName, ev.attrInfoEdit.attrInfo.name, ev.resource.name);
-
     }
 
 }
@@ -654,6 +653,16 @@ class SelectionInspector extends ScriptWidget {
                 if (section.editType.objects.indexOf(serial) != -1) {
 
                     sections.push(section);
+
+                    if (section.hasDynamicAttr) {
+
+                        var object = section.editType.getFirstObject();
+                        if (object) {
+                            var attrInfos = object.getAttributes();
+                            section.updateDynamicAttrInfos(attrInfos);
+                        }
+                    }
+
                     section.refresh();
                 }
 

+ 1 - 0
Script/AtomicEditor/ui/frames/inspector/SelectionSection.ts

@@ -7,6 +7,7 @@ import "./ComponentAttributeUI";
 
 abstract class SelectionSection extends Atomic.UISection {
 
+    hasDynamicAttr: boolean = false;
     editType: SerializableEditType;
     attrLayout: Atomic.UILayout;
     suppressed: boolean = false;