Init.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using Model;
  3. namespace Hotfix
  4. {
  5. public static class Init
  6. {
  7. public static void Start()
  8. {
  9. try
  10. {
  11. Hotfix.Scene.ModelScene = Game.Scene;
  12. Hotfix.Scene.ModelScene.AddComponent<OpcodeTypeComponent>();
  13. Hotfix.Scene.ModelScene.AddComponent<Model.MessageDispatherComponent>();
  14. Hotfix.Scene.ModelScene.AddComponent<NetOuterComponent>();
  15. Hotfix.Scene.ModelScene.AddComponent<ResourcesComponent>();
  16. Hotfix.Scene.ModelScene.AddComponent<BehaviorTreeComponent>();
  17. Hotfix.Scene.AddComponent<UIComponent>();
  18. Hotfix.Scene.GetComponent<EventComponent>().Run(EventIdType.InitSceneStart);
  19. }
  20. catch (Exception e)
  21. {
  22. Log.Error(e.ToStr());
  23. }
  24. }
  25. public static void Update()
  26. {
  27. try
  28. {
  29. ObjectEvents.Instance.Update();
  30. }
  31. catch (Exception e)
  32. {
  33. Log.Error(e.ToStr());
  34. }
  35. }
  36. public static void LateUpdate()
  37. {
  38. try
  39. {
  40. ObjectEvents.Instance.LateUpdate();
  41. }
  42. catch (Exception e)
  43. {
  44. Log.Error(e.ToStr());
  45. }
  46. }
  47. public static void OnApplicationQuit()
  48. {
  49. ObjectEvents.Close();
  50. Hotfix.Close();
  51. }
  52. }
  53. }