Game.cs 999 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using UnityEngine;
  2. namespace ETHotfix
  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() { Name = "ClientHotfix" };
  24. scene.GameObject.transform.SetParent(scene.GameObject.transform.Find("/Global"));
  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. public static void Close()
  43. {
  44. scene.Dispose();
  45. scene = null;
  46. eventSystem = null;
  47. objectPool.Dispose();
  48. objectPool = null;
  49. }
  50. }
  51. }