ClothMonitorMenu.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Magica Cloth.
  2. // Copyright (c) MagicaSoft, 2020-2022.
  3. // https://magicasoft.jp
  4. using UnityEditor;
  5. using UnityEngine;
  6. namespace MagicaCloth
  7. {
  8. /// <summary>
  9. /// MagicaClothの状態表示モニター
  10. /// </summary>
  11. public class ClothMonitorMenu : EditorWindow
  12. {
  13. public static ClothMonitorMenu Monitor { get; set; }
  14. [SerializeField]
  15. private ClothMonitorUI ui = new ClothMonitorUI();
  16. //=========================================================================================
  17. [MenuItem("Tools/Magica Cloth/Cloth Monitor", false)]
  18. public static void InitWindow()
  19. {
  20. GetWindow<ClothMonitorMenu>();
  21. }
  22. //=========================================================================================
  23. public ClothMonitorUI UI
  24. {
  25. get
  26. {
  27. return ui;
  28. }
  29. }
  30. //=========================================================================================
  31. private void Awake()
  32. {
  33. Init();
  34. }
  35. private void OnEnable()
  36. {
  37. EditorApplication.update += OnUpdate;
  38. ui.Enable();
  39. Monitor = this; // ギズモ表示登録
  40. }
  41. private void OnDisable()
  42. {
  43. Monitor = null; // ギズモ表示解除
  44. EditorApplication.update -= OnUpdate;
  45. ui.Disable();
  46. }
  47. private void OnDestroy()
  48. {
  49. ui.Destroy();
  50. }
  51. private void OnGUI()
  52. {
  53. ui.OnGUI();
  54. }
  55. void OnUpdate()
  56. {
  57. if (EditorApplication.isPlaying == false)
  58. return;
  59. if ((Time.frameCount % 30) == 0)
  60. Repaint();
  61. }
  62. //=========================================================================================
  63. void Init()
  64. {
  65. this.titleContent.text = "Cloth Monitor";
  66. ui.Init(this);
  67. }
  68. }
  69. }