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 void ShowRole(DialogueType left, DialogueType right) { HideAllRole(); if (dictionary.TryGetValue(left, out GameObject leftGo)) { leftGo.SetActive(true); leftGo.transform.position = leftPoint.position; leftGo.transform.rotation = leftPoint.rotation; } if (dictionary.TryGetValue(right, out GameObject rightGo)) { rightGo.SetActive(true); rightGo.transform.position = rightPoint.position; rightGo.transform.rotation = rightPoint.rotation; } } public void HideAllRole() { foreach (var value in dictionary.Values) { value.SetActive(false); } } public GameObject Get(DialogueType dialogueType) { dictionary.TryGetValue(dialogueType, out GameObject go); return go; } } }