using System.Collections.Generic; using Sirenix.OdinInspector; using UnityEditor; using UnityEngine; namespace UnityTest.ZXL { public class AnimatorManager : BaseAutoMono { public Dictionary> dictionary = new Dictionary>(); public List Get(string aniName) { dictionary.TryGetValue(aniName, out List list); return list; } #if UNITY_EDITOR [Button("Add")] void AutoAdd() { var activeObject = Selection.activeObject as GameObject; var animators = activeObject.GetComponentAllChild(); foreach (var animator in animators) { var animatorName = animator.name; if (animator.transform.parent != null) { animatorName = animator.transform.parent.name; } if (dictionary.ContainsKey(animatorName)) dictionary[animatorName].Add(animator); else dictionary.Add(animatorName, new List() {animator}); } } #endif } }