diff options
| author | Weicao-CatilGrass <1992414357@qq.com> | 2026-06-01 15:09:59 +0800 |
|---|---|---|
| committer | Weicao-CatilGrass <1992414357@qq.com> | 2026-06-01 15:09:59 +0800 |
| commit | e63c8557b3b860f0d1d1dcea69816fca35ebc6a6 (patch) | |
| tree | 328d6f684157b0b2957caf10e891b7a8035556e5 /Assets/Scripts/SoulCoreGameLoop/UI | |
| parent | cd6a2e619b80fe88279388470ebd4ea7e2fe5b3a (diff) | |
增加单向门
Diffstat (limited to 'Assets/Scripts/SoulCoreGameLoop/UI')
| -rw-r--r-- | Assets/Scripts/SoulCoreGameLoop/UI/MessageBox.cs | 41 | ||||
| -rw-r--r-- | Assets/Scripts/SoulCoreGameLoop/UI/MessageBox.cs.meta | 11 |
2 files changed, 52 insertions, 0 deletions
diff --git a/Assets/Scripts/SoulCoreGameLoop/UI/MessageBox.cs b/Assets/Scripts/SoulCoreGameLoop/UI/MessageBox.cs new file mode 100644 index 0000000..6680dee --- /dev/null +++ b/Assets/Scripts/SoulCoreGameLoop/UI/MessageBox.cs @@ -0,0 +1,41 @@ +using System; +using UnityEngine; +using TMPro; + +namespace SoulCoreGameLoop.UI +{ + [RequireComponent(typeof(Animator))] + public class MessageBox : MonoBehaviour, IUIEventSender<Message> + { + private static readonly int TriggerPlay = Animator.StringToHash("Play"); + + public TMP_Text messageText; + private Animator _animator; + + private void Awake() + { + _animator = GetComponent<Animator>(); + UIEventListener.Register(this); + } + + private void OnDestroy() + => UIEventListener.Unregister<Message>(); + + + public void OnReceive(Message evt) + { + messageText.text = evt.MessageText; + _animator.SetTrigger(TriggerPlay); + } + } + + public struct Message + { + public readonly string MessageText; + + public Message(string messageText) + { + MessageText = messageText; + } + } +}
\ No newline at end of file diff --git a/Assets/Scripts/SoulCoreGameLoop/UI/MessageBox.cs.meta b/Assets/Scripts/SoulCoreGameLoop/UI/MessageBox.cs.meta new file mode 100644 index 0000000..5aa4ca1 --- /dev/null +++ b/Assets/Scripts/SoulCoreGameLoop/UI/MessageBox.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 56cb74692951d66478469249ca604209 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: |
