forked from zxl/LaboratoryProtection
53 lines
1.3 KiB
C#
53 lines
1.3 KiB
C#
using System;
|
|
using Mono.Event;
|
|
using Sirenix.OdinInspector;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
namespace UnityTest.ZXL
|
|
{
|
|
public class RoleLabel : Label
|
|
{
|
|
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);
|
|
}
|
|
|
|
#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
|
|
}
|
|
|
|
public enum RoleLabelType
|
|
{
|
|
同学A,
|
|
同学B,
|
|
同学C,
|
|
同学D,
|
|
同学E,
|
|
同学F,
|
|
同学G,
|
|
}
|
|
} |