diff options
Diffstat (limited to 'Assets/Scripts/SoulCoreGameLoop')
| -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: |
