DebugTipInEditor.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System.Transactions;
  2. using Rokid.UXR.UI;
  3. using UnityEngine;
  4. namespace Rokid.UXR.UI
  5. {
  6. [ExecuteInEditMode]
  7. public class DebugTipInEditor : BaseUI
  8. {
  9. [SerializeField]
  10. private DebugTipPanel.DebugType debugType;
  11. private DebugTipPanel.DebugType oriDebugType;
  12. private bool showTip = true;
  13. private DebugTipPanel tipPanel;
  14. protected override void Start()
  15. {
  16. base.Start();
  17. oriDebugType = debugType;
  18. }
  19. private void OnEnable()
  20. {
  21. showTip = true;
  22. }
  23. private void OnDisable()
  24. {
  25. showTip = false;
  26. if (tipPanel != null)
  27. DestroyImmediate(tipPanel.gameObject);
  28. }
  29. private void Update()
  30. {
  31. if (showTip)
  32. {
  33. showTip = false;
  34. tipPanel = CreatePanel<DebugTipPanel>(true);
  35. tipPanel.Init(debugType);
  36. }
  37. if (oriDebugType != debugType)
  38. {
  39. showTip = true;
  40. oriDebugType = debugType;
  41. }
  42. }
  43. }
  44. }