EditorInit.cs 583 B

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