using System; using Mono.Event; using TMPro; using UnityEngine; namespace UnityTest.ZXL { public class RoleLabel : MonoBehaviour { public RoleLabelType roleLabelType; public TextMeshProUGUI roleName; public TextMeshProUGUI speakContent; private void Awake() { EventManager.Instance.Subscribe(RoleLabelEventArgs.EventId, RoleLabelEvent); roleName.text = roleLabelType.ToString(); } private void RoleLabelEvent(object sender, GameEventArgs e) { var args = e as RoleLabelEventArgs; speakContent.text = args.speakContent; } private void OnDestroy() { EventManager.Instance.Unsubscribe(RoleLabelEventArgs.EventId, RoleLabelEvent); } } public enum RoleLabelType { 同学A, 同学B, 同学C, 同学D, 同学F, 同学G, } }