diff --git a/src/Cinematic/Cells/AnimatorPlayer.cs b/src/Cinematic/Cells/AnimatorPlayer.cs index 7adf2ba..fe4fb6d 100644 --- a/src/Cinematic/Cells/AnimatorPlayer.cs +++ b/src/Cinematic/Cells/AnimatorPlayer.cs @@ -48,8 +48,12 @@ namespace UnityExplorer.UI.Panels this.favAnimations = new List(); - this.skinnedMeshes.AddRange(this.animator.wrappedObject.gameObject.GetComponentsInChildren(false)); - this.extraMeshes.AddRange(this.animator.wrappedObject.gameObject.GetComponentsInChildren(false)); + SearchMeshes(); + } + + public void SearchMeshes(){ + skinnedMeshes = new List(animator.wrappedObject.gameObject.GetComponentsInChildren(false)); + extraMeshes = new List(animator.wrappedObject.gameObject.GetComponentsInChildren(false)); } // Include the animations being played in other layers @@ -125,7 +129,7 @@ namespace UnityExplorer.UI.Panels } } - private List GetMeshes(){ + private List GetMeshesTransforms(){ List meshes = new List(); foreach (SkinnedMeshRenderer skinnedMesh in skinnedMeshes) { @@ -139,11 +143,16 @@ namespace UnityExplorer.UI.Panels public void OpenBonesPanel(){ if (skinnedMeshes.Count == 0 && extraMeshes.Count == 0) return; if (bonesManager == null){ - bonesManager = new BonesManager(UIManager.GetPanel(UIManager.Panels.AnimatorPanel).Owner, GetMeshes(), animator); + bonesManager = new BonesManager(UIManager.GetPanel(UIManager.Panels.AnimatorPanel).Owner, GetMeshesTransforms(), animator); } bonesManager.SetActive(true); } + public void MaybeResetBonesPanel(){ + if (bonesManager == null) return; + bonesManager.RefreshBones(GetMeshesTransforms()); + } + public void SetMeshesEnabled(bool value){ foreach (SkinnedMeshRenderer skinnedMesh in skinnedMeshes) { skinnedMesh.TryCast().enabled = value; diff --git a/src/UI/Panels/AnimatorPanel.cs b/src/UI/Panels/AnimatorPanel.cs index 02e21d2..1388ed4 100644 --- a/src/UI/Panels/AnimatorPanel.cs +++ b/src/UI/Panels/AnimatorPanel.cs @@ -76,6 +76,10 @@ namespace UnityExplorer.UI.Panels animators[i].animations.Add(animationClip); } newAnimators[newAnimatorsIndex] = animators[i]; + + // Reset meshes + newAnimators[newAnimatorsIndex].SearchMeshes(); + newAnimators[newAnimatorsIndex].MaybeResetBonesPanel(); } } } diff --git a/src/UI/Panels/BonesPanel.cs b/src/UI/Panels/BonesPanel.cs index 9a6b57c..7e970a6 100644 --- a/src/UI/Panels/BonesPanel.cs +++ b/src/UI/Panels/BonesPanel.cs @@ -35,6 +35,13 @@ namespace UnityExplorer.UI.Panels BuildBoneTrees(); } + public void RefreshBones(List bones) { + this.bones = bones; + boneTrees.Clear(); + BuildBoneTrees(); + boneScrollPool.Refresh(true, true); + } + private void BuildBoneTrees(){ BoneTree root = new BoneTree(animator.wrappedObject.gameObject, bones); if (root.obj != null){