ShowTextPanel.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using Common.Utility.CombatEvent;
  2. using Fort23.Core;
  3. using UnityEngine;
  4. namespace Fort23.Mono
  5. {
  6. [UIBinding(prefab = "ShowTextPanel")]
  7. public partial class ShowTextPanel : UIPanel
  8. {
  9. public static async CTask OpenShowTextPanel()
  10. {
  11. ShowTextPanel showTextPanel =
  12. await UIManager.Instance.LoadAndOpenPanel<ShowTextPanel>(null, UILayer.Top, isFocus: false);
  13. }
  14. private void Init()
  15. {
  16. }
  17. protected override void AddEvent()
  18. {
  19. EventManager.Instance.AddEventListener(CustomEventType.ShowText, ShowText);
  20. }
  21. protected async void ShowText(IEventData eventData)
  22. {
  23. ShowTextEventData showTextEventData = eventData as ShowTextEventData;
  24. Vector3 worldPos = showTextEventData.worldPos;
  25. string text = showTextEventData.text;
  26. Color Color = showTextEventData.Color;
  27. TextWidget widget =
  28. await UIManager.Instance.CreateGComponentForObject<TextWidget>(textWidget, null, transform,
  29. isInstance: true);
  30. Vector2 pos = UIManager.Instance.WorldToUIWorld(worldPos);
  31. widget.transform.position = pos;
  32. widget.ShowWidget(text, Color);
  33. }
  34. protected override void DelEvent()
  35. {
  36. EventManager.Instance.RemoveEventListener(CustomEventType.ShowText, ShowText);
  37. }
  38. public override void AddButtonEvent()
  39. {
  40. }
  41. }
  42. }