mirror of
https://github.com/originalnicodr/CinematicUnityExplorer.git
synced 2026-10-10 13:03:15 +08:00
Refactored the Animator pause to use start and stop playback (since disabling the whole animator could cause problems in some games). I am still disabling the animator as a fallback if the described method doesn't work.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user