EditorInit.cs 543 B

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using Base;
  3. using UnityEditor;
  4. using UnityEngine;
  5. using Model;
  6. namespace MyEditor
  7. {
  8. [InitializeOnLoad]
  9. internal class EditorInit
  10. {
  11. static EditorInit()
  12. {
  13. DisposerManager.Instance.Register("Editor", typeof(EditorInit).Assembly);
  14. EditorApplication.update += Update;
  15. }
  16. private static void Update()
  17. {
  18. if (Application.isPlaying)
  19. {
  20. return;
  21. }
  22. try
  23. {
  24. DisposerManager.Instance.Update();
  25. }
  26. catch (Exception e)
  27. {
  28. DisposerManager.Reset();
  29. Log.Error(e.ToString());
  30. }
  31. }
  32. }
  33. }