diff --git a/src/Cinematic/Cells/AnimatorCell.cs b/src/Cinematic/Cells/AnimatorCell.cs index e06b1d2..09674a7 100644 --- a/src/Cinematic/Cells/AnimatorCell.cs +++ b/src/Cinematic/Cells/AnimatorCell.cs @@ -116,7 +116,20 @@ namespace UnityExplorer.UI.Panels AnimatorToggle.isOn = true; AnimatorToggle.onValueChanged.AddListener(value => { //ExplorerCore.LogWarning($"Animator toggled: {animator} to {animator.enabled}"); - animator.enabled = value; + try { + Type animatorClass = ReflectionUtility.GetTypeByName("UnityEngine.Animator"); + if (value) { + MethodInfo stopPlayBack = animatorClass.GetMethod("StopPlayback"); + stopPlayBack.Invoke(animator.TryCast(), null); + } else { + MethodInfo startPlayBack = animatorClass.GetMethod("StartPlayback"); + startPlayBack.Invoke(animator.TryCast(), null); + } + } + catch { + // Fallback in case reflection isn't working + animator.enabled = value; + } // If we play an animation and we disable the animator then don't stop the animation when it finishes after we enable the animator again if (!value && stopAfterAnimationFinishes) stopAfterAnimationFinishes = false; } diff --git a/src/UI/Panels/AnimatorPanel.cs b/src/UI/Panels/AnimatorPanel.cs index 8aee48c..1627440 100644 --- a/src/UI/Panels/AnimatorPanel.cs +++ b/src/UI/Panels/AnimatorPanel.cs @@ -103,7 +103,20 @@ namespace UnityExplorer.UI.Panels // We gotta do this for the animators which cell are not being currently rendered. foreach (Animator animator in animators){ if (!shouldIgnoreMasterToggle[animator]){ - animator.enabled = enable; + try { + Type animatorClass = ReflectionUtility.GetTypeByName("UnityEngine.Animator"); + if (enable) { + MethodInfo stopPlayBack = animatorClass.GetMethod("StopPlayback"); + stopPlayBack.Invoke(animator.TryCast(), null); + } else { + MethodInfo startPlayBack = animatorClass.GetMethod("StartPlayback"); + startPlayBack.Invoke(animator.TryCast(), null); + } + } + catch { + // Fallback in case reflection isn't working + animator.enabled = enable; + } } } }