1
0
Fork 0
LaboratoryProtection/Assets/UnityTest/ZXL/Scripts/AnimatorManager.cs

32 lines
1.0 KiB
C#

using System.Collections.Generic;
using Sirenix.OdinInspector;
using UnityEditor;
using UnityEngine;
namespace UnityTest.ZXL
{
public class AnimatorManager : SerializedMonoBehaviour
{
public Dictionary<string, List<Animator>> dictionary = new Dictionary<string, List<Animator>>();
[Button("Add")]
void AutoAdd()
{
var activeObject = Selection.activeObject as GameObject;
var animators = activeObject.GetComponentAllChild<Animator>();
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>() { animator });
}
}
}
}