Game.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using UnityEngine;
  2. namespace ETModel
  3. {
  4. public static class Game
  5. {
  6. private static EventSystem eventSystem;
  7. public static EventSystem EventSystem
  8. {
  9. get
  10. {
  11. return eventSystem ?? (eventSystem = new EventSystem());
  12. }
  13. }
  14. private static Scene scene;
  15. public static Scene Scene
  16. {
  17. get
  18. {
  19. if (scene != null)
  20. {
  21. return scene;
  22. }
  23. scene = new Scene();
  24. scene.GameObject.transform.SetParent(GameObject.Find("/Global").transform);
  25. return scene;
  26. }
  27. }
  28. private static ObjectPool objectPool;
  29. public static ObjectPool ObjectPool
  30. {
  31. get
  32. {
  33. if (objectPool != null)
  34. {
  35. return objectPool;
  36. }
  37. objectPool = new ObjectPool();
  38. objectPool.GameObject.transform.SetParent(GameObject.Find("/Global").transform);
  39. return objectPool;
  40. }
  41. }
  42. private static Hotfix hotfix;
  43. public static Hotfix Hotfix
  44. {
  45. get
  46. {
  47. return hotfix ?? (hotfix = new Hotfix());
  48. }
  49. }
  50. public static void Close()
  51. {
  52. eventSystem = null;
  53. scene.Dispose();
  54. scene = null;
  55. objectPool.Dispose();
  56. objectPool = null;
  57. hotfix = null;
  58. }
  59. }
  60. }