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:
originalnicodr committed 2024-02-13 23:38:13 -03:00
1 parent 147b846995
commit 336373169a
2 files changed
+28 -2

No files matched your search

+14 -1
View File
@@ -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;
}
}
}
}