Share.cs 742 B

123456789101112131415161718192021222324252627282930313233
  1. namespace Base
  2. {
  3. /// <summary>
  4. /// 游戏和扩展编辑器都需要用到的数据放在这个Scene上面
  5. /// </summary>
  6. public sealed class Share: Entity
  7. {
  8. private static Scene share;
  9. public static Scene Scene
  10. {
  11. get
  12. {
  13. if (share == null)
  14. {
  15. share = new Scene("Share", SceneType.Share);
  16. share.AddComponent<EventComponent>();
  17. share.AddComponent<LogComponent>();
  18. GlobalConfigComponent globalConfigComponent = share.AddComponent<GlobalConfigComponent>();
  19. share.AddComponent<NetworkComponent, NetworkProtocol>(globalConfigComponent.GlobalProto.Protocol);
  20. }
  21. return share;
  22. }
  23. }
  24. public static void Close()
  25. {
  26. Entity scene = share;
  27. share = null;
  28. scene?.Dispose();
  29. }
  30. }
  31. }