2023-09-12 23:18:01 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
|
using UnityEditor;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace UnityTest.ZXL
|
|
|
|
|
{
|
2023-09-13 15:04:19 +08:00
|
|
|
|
public class AnimatorManager : BaseAutoMono<AnimatorManager>
|
2023-09-12 23:18:01 +08:00
|
|
|
|
{
|
|
|
|
|
public Dictionary<string, List<Animator>> dictionary = new Dictionary<string, List<Animator>>();
|
|
|
|
|
|
2023-09-18 00:01:05 +08:00
|
|
|
|
public List<GameObject> gameObjects = new List<GameObject>();
|
|
|
|
|
|
|
|
|
|
public void HideAll()
|
|
|
|
|
{
|
|
|
|
|
foreach (var go in gameObjects)
|
|
|
|
|
{
|
|
|
|
|
go.SetActive(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-13 15:04:19 +08:00
|
|
|
|
public List<Animator> Get(string aniName)
|
|
|
|
|
{
|
|
|
|
|
dictionary.TryGetValue(aniName, out List<Animator> list);
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-09-13 02:20:37 +08:00
|
|
|
|
#if UNITY_EDITOR
|
2023-09-18 00:01:05 +08:00
|
|
|
|
[Button("AddGo")]
|
|
|
|
|
void AutoAddGo()
|
|
|
|
|
{
|
|
|
|
|
gameObjects = new List<GameObject>();
|
|
|
|
|
for (var i = 0; i < transform.childCount; i++)
|
|
|
|
|
{
|
|
|
|
|
gameObjects.Add(transform.GetChild(i).gameObject);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-12 23:18:01 +08:00
|
|
|
|
[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
|
2023-09-18 00:01:05 +08:00
|
|
|
|
dictionary.Add(animatorName, new List<Animator>() { animator });
|
2023-09-12 23:18:01 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-09-13 02:20:37 +08:00
|
|
|
|
#endif
|
2023-09-12 23:18:01 +08:00
|
|
|
|
}
|
|
|
|
|
}
|