disable animations and state machines at prefab preview stage
@@ -604,6 +604,26 @@ impl SceneViewer {
.traverse_handle_iter(instance)
.collect::<FxHashSet<Handle<Node>>>();
+ // Disable animations and state machines.
+ for handle in nodes.iter() {
+ let node = &mut scene.graph[*handle];
+ if let Some(animation_player) =
+ node.query_component_mut::<AnimationPlayer>()
+ {
+ for animation in animation_player
+ .animations_mut()
+ .get_mut_silent()
+ .iter_mut()
+ {
+ animation.set_enabled(false);
+ }
+ } else if let Some(absm) =
+ node.query_component_mut::<AnimationBlendingStateMachine>()
+ {
+ absm.set_enabled(false);
+ }
+ }
+
self.preview_instance =
Some(PreviewInstance { instance, nodes });
}
@@ -889,26 +909,6 @@ impl SceneViewer {
if let Some(preview) = self.preview_instance.take() {
let scene = &mut engine.scenes[editor_scene.scene];
- // Disable animations and state machines.
- for handle in preview.nodes.iter() {
- let node = &mut scene.graph[*handle];
- if let Some(animation_player) =
- node.query_component_mut::<AnimationPlayer>()
- {
- for animation in animation_player
- .animations_mut()
- .get_mut_silent()
- .iter_mut()
- {
- animation.set_enabled(false);
- }
- } else if let Some(absm) =
- node.query_component_mut::<AnimationBlendingStateMachine>()
- {
- absm.set_enabled(false);
- }
- }
-
// Immediately after extract if from the scene to subgraph. This is required to not violate
// the rule of one place of execution, only commands allowed to modify the scene.
let sub_graph = scene.graph.take_reserve_sub_graph(preview.instance);
