From 5b98e68c40c220b5f0e5ee16823beb6f2831706e Mon Sep 17 00:00:00 2001 From: originalnicodr Date: Wed, 13 Mar 2024 23:50:53 -0300 Subject: [PATCH] Separated the "reset all" feature into another button in the animator panel. --- src/UI/Panels/AnimatorPanel.cs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/UI/Panels/AnimatorPanel.cs b/src/UI/Panels/AnimatorPanel.cs index d7cc3f4..6b316c4 100644 --- a/src/UI/Panels/AnimatorPanel.cs +++ b/src/UI/Panels/AnimatorPanel.cs @@ -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;