2023-09-20 00:15:45 +08:00
|
|
|
|
using System;
|
|
|
|
|
using Mono.Event;
|
2023-09-25 02:08:58 +08:00
|
|
|
|
using Sirenix.OdinInspector;
|
2023-09-20 00:15:45 +08:00
|
|
|
|
using TMPro;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace UnityTest.ZXL
|
|
|
|
|
{
|
2023-09-25 02:08:58 +08:00
|
|
|
|
public class RoleLabel : Label
|
2023-09-20 00:15:45 +08:00
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
2023-09-25 02:08:58 +08:00
|
|
|
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
[Button]
|
|
|
|
|
void Add()
|
|
|
|
|
{
|
|
|
|
|
roleName = transform.GetChild(0).GetChild(0).GetComponent<TextMeshProUGUI>();
|
|
|
|
|
speakContent = transform.GetChild(1).GetChild(0).GetComponent<TextMeshProUGUI>();
|
|
|
|
|
roleName.text = roleLabelType.ToString();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2023-09-20 00:15:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum RoleLabelType
|
|
|
|
|
{
|
|
|
|
|
同学A,
|
|
|
|
|
同学B,
|
|
|
|
|
同学C,
|
|
|
|
|
同学D,
|
2023-09-25 02:08:58 +08:00
|
|
|
|
同学E,
|
2023-09-20 00:15:45 +08:00
|
|
|
|
同学F,
|
|
|
|
|
同学G,
|
|
|
|
|
}
|
|
|
|
|
}
|