Alejandro Toledo преди 5 години
родител
ревизия
d2eff6a0f7

+ 14 - 0
inspector/src/components/actionTabs/tabs/propertyGrids/animations/animationListTree.tsx

@@ -63,6 +63,20 @@ export class AnimationListTree extends React.Component<
         };
     }
 
+    componentDidUpdate(prevProps: IAnimationListTreeProps) {
+        if (this.props.entity instanceof TargetedAnimation) {
+            if (
+                (this.props.entity as TargetedAnimation).animation !== (prevProps.entity as TargetedAnimation).animation
+            ) {
+                this.setState({ animationList: this.generateList() });
+            }
+        } else {
+            if ((this.props.entity as IAnimatable).animations !== (prevProps.entity as IAnimatable).animations) {
+                this.setState({ animationList: this.generateList() });
+            }
+        }
+    }
+
     deleteAnimation = () => {
         let currentSelected = this.props.selected;
         if (this.props.entity instanceof TargetedAnimation) {

+ 10 - 0
inspector/src/components/actionTabs/tabs/propertyGrids/animations/editorControls.tsx

@@ -177,6 +177,16 @@ export class EditorControls extends React.Component<
             isLoadTabOpen: false,
             isSaveTabOpen: false,
         });
+
+        if (this.props.entity instanceof TargetedAnimation) {
+            const animation = (this.props.entity as TargetedAnimation).animation;
+            this.props.selectAnimation(animation);
+        } else {
+            const animations = (this.props.entity as IAnimatable).animations;
+            if (animations !== null) {
+                this.props.selectAnimation(animations[0]);
+            }
+        }
     };
 
     editAnimation = (selected: Animation) => {