Separated the "reset all" feature into another button in the animator panel.

This commit is contained in:
originalnicodr committed 2024-03-13 23:50:53 -03:00
1 parent 67782b5c8b
commit 5b98e68c40
1 file changed
+13 -7
+13 -7
View File
@@ -53,13 +53,7 @@ namespace UnityExplorer.UI.Panels
private void FindAllAnimators(){
// Enable all animators on refresh
if (animators.Count != 0) {
foreach (AnimatorPlayer animatorPlayer in animators)
{
animatorPlayer.ResetAnimation();
}
masterAnimatorToggle.isOn = true; // Will also trigger "MasterToggleAnimators(true)"
}
masterAnimatorToggle.isOn = true; // Will also trigger "MasterToggleAnimators(true)"
Type searchType = ReflectionUtility.GetTypeByName("UnityEngine.Animator");
searchType = searchType is Type type ? type : searchType.GetActualType();
@@ -83,6 +77,14 @@ namespace UnityExplorer.UI.Panels
animatorScrollPool.Refresh(true, false);
}
private void ResetAllAnimators(){
foreach (AnimatorPlayer animatorPlayer in animators)
{
animatorPlayer.ResetAnimation();
}
}
public void MasterToggleAnimators(bool enable){
// Load animators for the first time if there are not any
if (animators.Count == 0) FindAllAnimators();
@@ -114,6 +116,10 @@ namespace UnityExplorer.UI.Panels
UIFactory.SetLayoutElement(updateAnimators.GameObject, minWidth: 150, minHeight: 25);
updateAnimators.OnClick += FindAllAnimators;
ButtonRef resetAnimators = UIFactory.CreateButton(firstGroup, "ResetAnimators", "Reset Animators");
UIFactory.SetLayoutElement(resetAnimators.GameObject, minWidth: 150, minHeight: 25);
resetAnimators.OnClick += ResetAllAnimators;
GameObject animatorObj = UIFactory.CreateToggle(firstGroup, $"Master Animation Toggle", out masterAnimatorToggle, out Text masterAnimatorText);
UIFactory.SetLayoutElement(animatorObj, minHeight: 25);
masterAnimatorToggle.isOn = true;