File tree Expand file tree Collapse file tree
src/LitMotion/Assets/LitMotion.Animation/Editor Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33using UnityEditor . UIElements ;
44using System . Collections . Generic ;
55using UnityEngine ;
6+ using UnityEditor . SceneManagement ;
67
78namespace LitMotion . Animation . Editor
89{
@@ -192,7 +193,14 @@ VisualElement CreateDebugPanel()
192193 flexGrow = 1f ,
193194 }
194195 } ;
195- var playButton = new Button ( ( ) => ( ( LitMotionAnimation ) target ) . Play ( ) )
196+ var playButton = new Button ( ( ) => {
197+ ( ( LitMotionAnimation ) target ) . Play ( ) ;
198+ if ( PrefabStageUtility . GetCurrentPrefabStage ( ) != null )
199+ {
200+ PrefabStage . prefabStageClosing -= OnPrefabStageClosing ;
201+ PrefabStage . prefabStageClosing += OnPrefabStageClosing ;
202+ }
203+ } )
196204 {
197205 text = "Play" ,
198206 style = {
@@ -345,5 +353,14 @@ bool IsActive()
345353 {
346354 return ! ( ( LitMotionAnimation ) target ) . IsActive ;
347355 }
356+
357+ void OnPrefabStageClosing ( PrefabStage stage )
358+ {
359+ PrefabStage . prefabStageClosing -= OnPrefabStageClosing ;
360+ foreach ( var i in stage . prefabContentsRoot . GetComponentsInChildren < LitMotionAnimation > ( true ) )
361+ {
362+ i . Stop ( ) ;
363+ }
364+ }
348365 }
349366}
You can’t perform that action at this time.
0 commit comments