FloatingValuesController.cs 837 B

123456789101112131415161718192021222324252627282930
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Sirenix.OdinInspector;
  5. using KairoEngine.Core;
  6. namespace KairoEngine.UI
  7. {
  8. public class FloatingValuesController : MonoBehaviour
  9. {
  10. public GameObject floatingValueUiPrefab;
  11. public Transform canvasParent;
  12. void OnEnable()
  13. {
  14. FloatingMessageEvents.OnMessage += OnMessage;
  15. }
  16. void OnDisable()
  17. {
  18. FloatingMessageEvents.OnMessage -= OnMessage;
  19. }
  20. private void OnMessage(string message, Vector3 targetPos, float offset, float time, float fontSize)
  21. {
  22. GameObject obj = Instantiate(floatingValueUiPrefab, canvasParent);
  23. obj.GetComponent<FloatingValueUi>().Setup(targetPos, message, offset, time, fontSize);
  24. }
  25. }
  26. }