using System; using System.Collections.Generic; using Sirenix.OdinInspector; using UnityEngine; namespace UnityTest.ZXL { public class DialogueRoleManager : BaseAutoMono { public Transform leftPoint; public Transform rightPoint; public Dictionary dictionary = new Dictionary(); private void Awake() { HideAllRole(); } #if UNITY_EDITOR [Button] #endif public List ShowRole(DialogueType left, DialogueType right) { HideAllRole(); if (!dictionary.TryGetValue(left, out GameObject leftGo)) return null; leftPoint.gameObject.SetActive(true); leftGo.SetActive(true); leftGo.transform.position = leftPoint.position; leftGo.transform.rotation = leftPoint.rotation; if (!dictionary.TryGetValue(right, out GameObject rightGo)) return null; rightPoint.gameObject.SetActive(true); rightGo.SetActive(true); rightGo.transform.position = rightPoint.position; rightGo.transform.rotation = rightPoint.rotation; List list = new List(); var leftAni = leftGo.GetComponent(); list.Add(leftAni); var rightAni = rightGo.GetComponent(); list.Add(rightAni); return list; } public void HideAllRole() { foreach (var value in dictionary.Values) { value.SetActive(false); value.GetComponent().enabled = false; } leftPoint.gameObject.SetActive(true); rightPoint.gameObject.SetActive(true); } public GameObject Get(DialogueType dialogueType) { dictionary.TryGetValue(dialogueType, out GameObject go); return go; } } }