Преглед изворни кода

1.增加ENABLE_VIEW宏,不需要ENABLE_CODES就能显示层级树,ENABLE_CODES主要是提供一种机制给编辑器访问逻辑层代码
2.调整Scene管理客户端服务端的Scene分别由ClientSceneManagerComponent跟ServerSceneManagerComponent管理

tanghai пре 3 година
родитељ
комит
ffa70a5238
45 измењених фајлова са 235 додато и 165 уклоњено
  1. 2 2
      DotNet/Model/DotNet.Model.csproj
  2. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Login/EnterMapHelper.cs
  3. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Move/M2C_StopHandler.cs
  4. 2 2
      Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Move/MoveHelper.cs
  5. 2 2
      Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Scene/SceneChangeHelper.cs
  6. 2 4
      Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Scene/SceneFactory.cs
  7. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Unit/M2C_CreateMyUnitHandler.cs
  8. 2 2
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/EntryEvent2_InitServer.cs
  9. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Gate/C2G_EnterMapHandler.cs
  10. 1 7
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Helper/SceneFactory.cs
  11. 2 2
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Robot/RobotCaseHelper.cs
  12. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Robot/RobotManagerComponentSystem.cs
  13. 0 20
      Unity/Assets/Scripts/Codes/Hotfix/Share/Module/Scene/ClientSceneFlagComponentSystem.cs
  14. 6 13
      Unity/Assets/Scripts/Codes/Hotfix/Share/Module/Scene/ClientSceneManagerComponentSystem.cs
  15. 35 0
      Unity/Assets/Scripts/Codes/Hotfix/Share/Module/Scene/ServerSceneManagerComponentSystem.cs
  16. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Share/Module/Scene/ServerSceneManagerComponentSystem.cs.meta
  17. 1 1
      Unity/Assets/Scripts/Codes/HotfixView/Client/Demo/EntryEvent3_InitClient.cs
  18. 8 0
      Unity/Assets/Scripts/Codes/Model/Client/Demo/Move.meta
  19. 11 0
      Unity/Assets/Scripts/Codes/Model/Client/Demo/Move/Wait_UnitStop.cs
  20. 1 1
      Unity/Assets/Scripts/Codes/Model/Client/Demo/Move/Wait_UnitStop.cs.meta
  21. 8 0
      Unity/Assets/Scripts/Codes/Model/Client/Demo/Scene.meta
  22. 13 0
      Unity/Assets/Scripts/Codes/Model/Client/Demo/Scene/Wait_CreateMyUnit.cs
  23. 1 1
      Unity/Assets/Scripts/Codes/Model/Client/Demo/Scene/Wait_CreateMyUnit.cs.meta
  24. 11 0
      Unity/Assets/Scripts/Codes/Model/Client/Demo/Scene/Wait_SceneChangeFinish.cs
  25. 11 0
      Unity/Assets/Scripts/Codes/Model/Client/Demo/Scene/Wait_SceneChangeFinish.cs.meta
  26. 8 0
      Unity/Assets/Scripts/Codes/Model/Share/Demo.meta
  27. 1 24
      Unity/Assets/Scripts/Codes/Model/Share/Demo/EventType.cs
  28. 1 1
      Unity/Assets/Scripts/Codes/Model/Share/Demo/EventType.cs.meta
  29. 0 9
      Unity/Assets/Scripts/Codes/Model/Share/Module/Scene/ClientSceneFlagComponent.cs
  30. 0 3
      Unity/Assets/Scripts/Codes/Model/Share/Module/Scene/ClientSceneManagerComponent.cs
  31. 9 0
      Unity/Assets/Scripts/Codes/Model/Share/Module/Scene/ServerSceneManagerComponent.cs
  32. 11 0
      Unity/Assets/Scripts/Codes/Model/Share/Module/Scene/ServerSceneManagerComponent.cs.meta
  33. 2 5
      Unity/Assets/Scripts/Codes/Model/Share/Module/Unit/Unit.cs
  34. 0 34
      Unity/Assets/Scripts/Codes/Model/Share/WaitType.cs
  35. 1 1
      Unity/Assets/Scripts/Core/Entity/EntitySceneFactory.cs
  36. 2 4
      Unity/Assets/Scripts/Core/Entity/Scene.cs
  37. 1 1
      Unity/Assets/Scripts/Core/Object/ComponentView.cs
  38. 4 6
      Unity/Assets/Scripts/Core/Object/Entity.cs
  39. 59 9
      Unity/Assets/Scripts/Editor/BuildEditor/BuildHelper.cs
  40. 1 1
      Unity/Assets/Scripts/Editor/ComponentViewEditor/ComponentViewEditor.cs
  41. 1 1
      Unity/Assets/Scripts/Editor/ComponentViewEditor/Tree/EntityTreeView.cs
  42. 1 1
      Unity/Assets/Scripts/Editor/ComponentViewEditor/Tree/EntityTreeViewItem.cs
  43. 1 1
      Unity/Assets/Scripts/Editor/ComponentViewEditor/Tree/EntityTreeWindow.cs
  44. 6 0
      Unity/Assets/Scripts/Mono/Define.cs
  45. 1 1
      Unity/ProjectSettings/ProjectSettings.asset

+ 2 - 2
DotNet/Model/DotNet.Model.csproj

@@ -11,11 +11,11 @@
     </PropertyGroup>
     <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
         <DefineConstants>DOTNET</DefineConstants>
-        <OutputPath>..\..\Bin\</OutputPath>
+        <OutputPath>..\..\Bin\</OutputPath> 
         <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
         <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
     </PropertyGroup>
-    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
+    <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> 
         <DefineConstants>DOTNET</DefineConstants>
         <OutputPath>..\..\Bin\</OutputPath>
         <AllowUnsafeBlocks>true</AllowUnsafeBlocks>

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Login/EnterMapHelper.cs

@@ -13,7 +13,7 @@ namespace ET.Client
                 clientScene.GetComponent<PlayerComponent>().MyId = g2CEnterMap.MyId;
                 
                 // 等待场景切换完成
-                await clientScene.GetComponent<ObjectWait>().Wait<WaitType.Wait_SceneChangeFinish>();
+                await clientScene.GetComponent<ObjectWait>().Wait<Wait_SceneChangeFinish>();
                 
                 EventSystem.Instance.Publish(clientScene, new EventType.EnterMapFinish());
             }

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Move/M2C_StopHandler.cs

@@ -20,7 +20,7 @@ namespace ET.Client
 			moveComponent.Stop();
 			unit.Position = pos;
 			unit.Rotation = rotation;
-			unit.GetComponent<ObjectWait>()?.Notify(new WaitType.Wait_UnitStop() {Error = message.Error});
+			unit.GetComponent<ObjectWait>()?.Notify(new Wait_UnitStop() {Error = message.Error});
 			await ETTask.CompletedTask;
 		}
 	}

+ 2 - 2
Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Move/MoveHelper.cs

@@ -14,10 +14,10 @@ namespace ET.Client
             ObjectWait objectWait = unit.GetComponent<ObjectWait>();
             
             // 要取消上一次的移动协程
-            objectWait.Notify(new WaitType.Wait_UnitStop() { Error = WaitTypeError.Cancel });
+            objectWait.Notify(new Wait_UnitStop() { Error = WaitTypeError.Cancel });
             
             // 一直等到unit发送stop
-            WaitType.Wait_UnitStop waitUnitStop = await objectWait.Wait<WaitType.Wait_UnitStop>(cancellationToken);
+            Wait_UnitStop waitUnitStop = await objectWait.Wait<Wait_UnitStop>(cancellationToken);
             return waitUnitStop.Error;
         }
         

+ 2 - 2
Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Scene/SceneChangeHelper.cs

@@ -16,7 +16,7 @@
             EventSystem.Instance.Publish(clientScene, new EventType.SceneChangeStart());
 
             // 等待CreateMyUnit的消息
-            WaitType.Wait_CreateMyUnit waitCreateMyUnit = await clientScene.GetComponent<ObjectWait>().Wait<WaitType.Wait_CreateMyUnit>();
+            Wait_CreateMyUnit waitCreateMyUnit = await clientScene.GetComponent<ObjectWait>().Wait<Wait_CreateMyUnit>();
             M2C_CreateMyUnit m2CCreateMyUnit = waitCreateMyUnit.Message;
             Unit unit = UnitFactory.Create(currentScene, m2CCreateMyUnit.Unit);
             unitComponent.Add(unit);
@@ -26,7 +26,7 @@
             EventSystem.Instance.Publish(currentScene, new EventType.SceneChangeFinish());
 
             // 通知等待场景切换的协程
-            clientScene.GetComponent<ObjectWait>().Notify(new WaitType.Wait_SceneChangeFinish());
+            clientScene.GetComponent<ObjectWait>().Notify(new Wait_SceneChangeFinish());
         }
     }
 }

+ 2 - 4
Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Scene/SceneFactory.cs

@@ -4,13 +4,11 @@ namespace ET.Client
 {
     public static class SceneFactory
     {
-        public static async ETTask<Scene> CreateClientScene(int zone, string name, Entity parent)
+        public static async ETTask<Scene> CreateClientScene(int zone, string name)
         {
             await ETTask.CompletedTask;
             
-            Scene clientScene = EntitySceneFactory.CreateScene(zone, SceneType.Client, name, parent);
-            clientScene.AddComponent<ClientSceneFlagComponent>();
-            
+            Scene clientScene = EntitySceneFactory.CreateScene(zone, SceneType.Client, name, ClientSceneManagerComponent.Instance);
             clientScene.AddComponent<CurrentScenesComponent>();
             clientScene.AddComponent<ObjectWait>();
             clientScene.AddComponent<PlayerComponent>();

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Unit/M2C_CreateMyUnitHandler.cs

@@ -6,7 +6,7 @@
 		protected override async ETTask Run(Session session, M2C_CreateMyUnit message)
 		{
 			// 通知场景切换协程继续往下走
-			session.DomainScene().GetComponent<ObjectWait>().Notify(new WaitType.Wait_CreateMyUnit() {Message = message});
+			session.DomainScene().GetComponent<ObjectWait>().Notify(new Wait_CreateMyUnit() {Message = message});
 			await ETTask.CompletedTask;
 		}
 	}

+ 2 - 2
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/EntryEvent2_InitServer.cs

@@ -14,7 +14,7 @@ namespace ET.Server
             // 访问location server的组件
             Game.Scene.AddComponent<LocationProxyComponent>();
             Game.Scene.AddComponent<ActorMessageDispatcherComponent>();
-            
+            Game.Scene.AddComponent<ServerSceneManagerComponent>();
             Game.Scene.AddComponent<RobotCaseDispatcherComponent>();
             Game.Scene.AddComponent<RobotCaseComponent>();
 
@@ -30,7 +30,7 @@ namespace ET.Server
                     var processScenes = StartSceneConfigCategory.Instance.GetByProcess(Options.Instance.Process);
                     foreach (StartSceneConfig startConfig in processScenes)
                     {
-                        await SceneFactory.Create(Game.Scene, startConfig.Id, startConfig.InstanceId, startConfig.Zone, startConfig.Name,
+                        await SceneFactory.CreateServerScene(ServerSceneManagerComponent.Instance, startConfig.Id, startConfig.InstanceId, startConfig.Zone, startConfig.Name,
                             startConfig.Type, startConfig);
                     }
 

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Gate/C2G_EnterMapHandler.cs

@@ -12,7 +12,7 @@ namespace ET.Server
 
 			// 在Gate上动态创建一个Map Scene,把Unit从DB中加载放进来,然后传送到真正的Map中,这样登陆跟传送的逻辑就完全一样了
 			GateMapComponent gateMapComponent = player.AddComponent<GateMapComponent>();
-			gateMapComponent.Scene = await SceneFactory.Create(gateMapComponent, "GateMap", SceneType.Map);
+			gateMapComponent.Scene = await SceneFactory.CreateServerScene(gateMapComponent, player.Id, IdGenerater.Instance.GenerateInstanceId(), gateMapComponent.DomainZone(), "GateMap", SceneType.Map);
 
 			Scene scene = gateMapComponent.Scene;
 			

+ 1 - 7
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Helper/SceneFactory.cs

@@ -4,13 +4,7 @@ namespace ET.Server
 {
     public static class SceneFactory
     {
-        public static async ETTask<Scene> Create(Entity parent, string name, SceneType sceneType)
-        {
-            long instanceId = IdGenerater.Instance.GenerateInstanceId();
-            return await Create(parent, instanceId, instanceId, parent.DomainZone(), name, sceneType);
-        }
-        
-        public static async ETTask<Scene> Create(Entity parent, long id, long instanceId, int zone, string name, SceneType sceneType, StartSceneConfig startSceneConfig = null)
+        public static async ETTask<Scene> CreateServerScene(Entity parent, long id, long instanceId, int zone, string name, SceneType sceneType, StartSceneConfig startSceneConfig = null)
         {
             await ETTask.CompletedTask;
             Scene scene = EntitySceneFactory.CreateScene(id, instanceId, zone, sceneType, name, parent);

+ 2 - 2
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Robot/RobotCaseHelper.cs

@@ -64,7 +64,7 @@ namespace ET.Server
             Scene clientScene = null;
             try
             {
-                clientScene = await Client.SceneFactory.CreateClientScene(zone, name, self);
+                clientScene = await Client.SceneFactory.CreateClientScene(zone, name);
                 await Client.LoginHelper.Login(clientScene, zone.ToString(), zone.ToString());
                 await Client.EnterMapHelper.EnterMapAsync(clientScene);
                 Log.Debug($"create robot ok: {zone}");
@@ -84,7 +84,7 @@ namespace ET.Server
 
             try
             {
-                clientScene = await Client.SceneFactory.CreateClientScene(zone, $"Robot_{zone}", self);
+                clientScene = await Client.SceneFactory.CreateClientScene(zone, $"Robot_{zone}");
                 await Client.LoginHelper.Login(clientScene, zone.ToString(), zone.ToString());
                 await Client.EnterMapHelper.EnterMapAsync(clientScene);
                 Log.Debug($"create robot ok: {zone}");

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Robot/RobotManagerComponentSystem.cs

@@ -10,7 +10,7 @@ namespace ET.Server
             Scene clientScene = null;
             try
             {
-                clientScene = await Client.SceneFactory.CreateClientScene(zone, "Robot", self);
+                clientScene = await Client.SceneFactory.CreateClientScene(zone, "Robot");
                 await Client.LoginHelper.Login(clientScene, zone.ToString(), zone.ToString());
                 await Client.EnterMapHelper.EnterMapAsync(clientScene);
                 Log.Debug($"create robot ok: {zone}");

+ 0 - 20
Unity/Assets/Scripts/Codes/Hotfix/Share/Module/Scene/ClientSceneFlagComponentSystem.cs

@@ -1,20 +0,0 @@
-namespace ET
-{
-    [ObjectSystem]
-    public class ClientSceneFlagComponentDestroySystem: DestroySystem<ClientSceneFlagComponent>
-    {
-        protected override void Destroy(ClientSceneFlagComponent self)
-        {
-            ClientSceneManagerComponent.Instance.Remove(self.DomainZone());
-        }
-    }
-
-    [ObjectSystem]
-    public class ClientSceneFlagComponentAwakeSystem: AwakeSystem<ClientSceneFlagComponent>
-    {
-        protected override void Awake(ClientSceneFlagComponent self)
-        {
-            ClientSceneManagerComponent.Instance.Add(self.GetParent<Scene>());
-        }
-    }
-}

+ 6 - 13
Unity/Assets/Scripts/Codes/Hotfix/Share/Module/Scene/ClientSceneManagerComponentSystem.cs

@@ -1,6 +1,4 @@
-using System;
-
-namespace ET
+namespace ET
 {
     [FriendOf(typeof(ClientSceneManagerComponent))]
     public static class ClientSceneManagerComponentSystem
@@ -19,7 +17,7 @@ namespace ET
         {
             protected override void Destroy(ClientSceneManagerComponent self)
             {
-                self.ClientScenes.Clear();
+                ClientSceneManagerComponent.Instance = null;
             }
         }
         
@@ -28,20 +26,15 @@ namespace ET
             return ClientSceneManagerComponent.Instance.Get(entity.DomainZone());
         }
         
-        public static void Add(this ClientSceneManagerComponent self, Scene clientScene)
-        {
-            self.ClientScenes.Add(clientScene.Zone, clientScene);
-        }
-        
-        public static Scene Get(this ClientSceneManagerComponent self, int zone)
+        public static Scene Get(this ClientSceneManagerComponent self, int id)
         {
-            self.ClientScenes.TryGetValue(zone, out Scene scene);
+            Scene scene = self.GetChild<Scene>(id);
             return scene;
         }
         
-        public static void Remove(this ClientSceneManagerComponent self, int zone)
+        public static void Remove(this ClientSceneManagerComponent self, int id)
         {
-            self.ClientScenes.Remove(zone);
+            self.RemoveChild(id);
         }
     }
 }

+ 35 - 0
Unity/Assets/Scripts/Codes/Hotfix/Share/Module/Scene/ServerSceneManagerComponentSystem.cs

@@ -0,0 +1,35 @@
+namespace ET
+{
+    [FriendOf(typeof(ServerSceneManagerComponent))]
+    public static class ServerSceneManagerComponentSystem
+    {
+        [ObjectSystem]
+        public class ServerSceneManagerComponentAwakeSystem: AwakeSystem<ServerSceneManagerComponent>
+        {
+            protected override void Awake(ServerSceneManagerComponent self)
+            {
+                ServerSceneManagerComponent.Instance = self;
+            }
+        }
+
+        [ObjectSystem]
+        public class ServerSceneManagerComponentDestroySystem: DestroySystem<ServerSceneManagerComponent>
+        {
+            protected override void Destroy(ServerSceneManagerComponent self)
+            {
+                ServerSceneManagerComponent.Instance = null;
+            }
+        }
+        
+        public static Scene Get(this ServerSceneManagerComponent self, int id)
+        {
+            Scene scene = self.GetChild<Scene>(id);
+            return scene;
+        }
+        
+        public static void Remove(this ServerSceneManagerComponent self, int id)
+        {
+            self.RemoveChild(id);
+        }
+    }
+}

+ 1 - 1
Unity/Assets/Scripts/Codes/Model/Share/Module/Scene/ClientSceneFlagComponent.cs.meta → Unity/Assets/Scripts/Codes/Hotfix/Share/Module/Scene/ServerSceneManagerComponentSystem.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: 92b51ee3607711d408524a14777db73b
+guid: d288bfc3ad8759446a3aab1329c79acd
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 1 - 1
Unity/Assets/Scripts/Codes/HotfixView/Client/Demo/EntryEvent3_InitClient.cs

@@ -15,7 +15,7 @@ namespace ET.Client
 
             await ResourcesComponent.Instance.LoadBundleAsync("unit.unity3d");
             
-            Scene clientScene = await SceneFactory.CreateClientScene(1, "Game", Game.Scene);
+            Scene clientScene = await SceneFactory.CreateClientScene(1, "Game");
             
             await EventSystem.Instance.PublishAsync(clientScene, new EventType.AppStartInitFinish());
         }

+ 8 - 0
Unity/Assets/Scripts/Codes/Model/Client/Demo/Move.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: cdd42c6d6d9715a419cdb969e085d1ce
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 11 - 0
Unity/Assets/Scripts/Codes/Model/Client/Demo/Move/Wait_UnitStop.cs

@@ -0,0 +1,11 @@
+namespace ET.Client
+{
+    public struct Wait_UnitStop: IWaitType
+    {
+        public int Error
+        {
+            get;
+            set;
+        }
+    }
+}

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Share/Module/Scene/ClientSceneFlagComponentSystem.cs.meta → Unity/Assets/Scripts/Codes/Model/Client/Demo/Move/Wait_UnitStop.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: 90a0dea5a58b52149854616ce151f2aa
+guid: 6d2c25b826caf964298ab1b3062672d0
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 8 - 0
Unity/Assets/Scripts/Codes/Model/Client/Demo/Scene.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 37075148f91c75a4fa1dd1949675fdfc
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 13 - 0
Unity/Assets/Scripts/Codes/Model/Client/Demo/Scene/Wait_CreateMyUnit.cs

@@ -0,0 +1,13 @@
+namespace ET.Client
+{
+    public struct Wait_CreateMyUnit: IWaitType
+    {
+        public int Error
+        {
+            get;
+            set;
+        }
+
+        public M2C_CreateMyUnit Message;
+    }
+}

+ 1 - 1
Unity/Assets/Scripts/Codes/Model/Share/WaitType.cs.meta → Unity/Assets/Scripts/Codes/Model/Client/Demo/Scene/Wait_CreateMyUnit.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: e0818fd5d35987f408a168c85f68548a
+guid: db73d25ad4edab142a541763978973da
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 11 - 0
Unity/Assets/Scripts/Codes/Model/Client/Demo/Scene/Wait_SceneChangeFinish.cs

@@ -0,0 +1,11 @@
+namespace ET.Client
+{
+    public struct Wait_SceneChangeFinish: IWaitType
+    {
+        public int Error
+        {
+            get;
+            set;
+        }
+    }
+}

+ 11 - 0
Unity/Assets/Scripts/Codes/Model/Client/Demo/Scene/Wait_SceneChangeFinish.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: e32ab4f9dd1b5a54fa99e7b9d211d5d6
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 8 - 0
Unity/Assets/Scripts/Codes/Model/Share/Demo.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: a8b51975ee1f907459aad5d4013c0d14
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 1 - 24
Unity/Assets/Scripts/Codes/Model/Share/EventType.cs → Unity/Assets/Scripts/Codes/Model/Share/Demo/EventType.cs

@@ -1,13 +1,7 @@
-using UnityEngine;
-
-namespace ET
+namespace ET
 {
     namespace EventType
     {
-        public struct AppStart
-        {
-        }
-
         public struct SceneChangeStart
         {
         }
@@ -15,11 +9,6 @@ namespace ET
         public struct SceneChangeFinish
         {
         }
-
-        public struct PingChange
-        {
-            public long Ping;
-        }
         
         public struct AfterCreateClientScene
         {
@@ -28,10 +17,6 @@ namespace ET
         public struct AfterCreateCurrentScene
         {
         }
-        
-        public struct AfterCreateLoginScene
-        {
-        }
 
         public struct AppStartInitFinish
         {
@@ -41,14 +26,6 @@ namespace ET
         {
         }
 
-        public struct LoadingBegin
-        {
-        }
-
-        public struct LoadingFinish
-        {
-        }
-
         public struct EnterMapFinish
         {
         }

+ 1 - 1
Unity/Assets/Scripts/Codes/Model/Share/EventType.cs.meta → Unity/Assets/Scripts/Codes/Model/Share/Demo/EventType.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: f9a5eee5ed014a643a4e1ba606defe24
+guid: 1ee78eb138185bc45a7eb3b3bb3d7898
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 0 - 9
Unity/Assets/Scripts/Codes/Model/Share/Module/Scene/ClientSceneFlagComponent.cs

@@ -1,9 +0,0 @@
-using System.Collections.Generic;
-
-namespace ET
-{
-    [ComponentOf(typeof(Scene))]
-    public class ClientSceneFlagComponent: Entity, IAwake, IDestroy
-    {
-    }
-}

+ 0 - 3
Unity/Assets/Scripts/Codes/Model/Share/Module/Scene/ClientSceneManagerComponent.cs

@@ -1,5 +1,3 @@
-using System.Collections.Generic;
-
 namespace ET
 {
     [ComponentOf(typeof(Scene))]
@@ -7,6 +5,5 @@ namespace ET
     {
         [StaticField]
         public static ClientSceneManagerComponent Instance;
-        public Dictionary<int, Scene> ClientScenes = new Dictionary<int, Scene>();
     }
 }

+ 9 - 0
Unity/Assets/Scripts/Codes/Model/Share/Module/Scene/ServerSceneManagerComponent.cs

@@ -0,0 +1,9 @@
+namespace ET
+{
+    [ComponentOf(typeof(Scene))]
+    public class ServerSceneManagerComponent: Entity, IAwake, IDestroy
+    {
+        [StaticField]
+        public static ServerSceneManagerComponent Instance;
+    }
+}

+ 11 - 0
Unity/Assets/Scripts/Codes/Model/Share/Module/Scene/ServerSceneManagerComponent.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: ef838de56fde7e243a3f6ddebd43c184
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 2 - 5
Unity/Assets/Scripts/Codes/Model/Share/Module/Unit/Unit.cs

@@ -5,7 +5,7 @@ using UnityEngine;
 namespace ET
 {
     [ChildOf(typeof(UnitComponent))]
-    [DebuggerDisplay("ViewGoName,nq")]
+    [DebuggerDisplay("ViewName,nq")]
     public class Unit: Entity, IAwake<int>
     {
         public int ConfigId { get; set; } //配置表id
@@ -51,15 +51,12 @@ namespace ET
             }
         }
 
-        
-#if ENABLE_CODES
-        protected override string ViewGoName
+        protected override string ViewName
         {
             get
             {
                 return $"{this.GetType().Name} ({this.Id})";
             }
         }
-#endif
     }
 }

+ 0 - 34
Unity/Assets/Scripts/Codes/Model/Share/WaitType.cs

@@ -1,34 +0,0 @@
-namespace ET
-{
-    namespace WaitType
-    {
-        public struct Wait_UnitStop: IWaitType
-        {
-            public int Error
-            {
-                get;
-                set;
-            }
-        }
-        
-        public struct Wait_CreateMyUnit: IWaitType
-        {
-            public int Error
-            {
-                get;
-                set;
-            }
-
-            public M2C_CreateMyUnit Message;
-        }
-        
-        public struct Wait_SceneChangeFinish: IWaitType
-        {
-            public int Error
-            {
-                get;
-                set;
-            }
-        }
-    }
-}

+ 1 - 1
Unity/Assets/Scripts/Core/Entity/EntitySceneFactory.cs

@@ -12,7 +12,7 @@
         public static Scene CreateScene(int zone, SceneType sceneType, string name, Entity parent = null)
         {
             long instanceId = IdGenerater.Instance.GenerateInstanceId();
-            Scene scene = new Scene(instanceId, zone, sceneType, name, parent);
+            Scene scene = new Scene(zone, instanceId, zone, sceneType, name, parent);
             return scene;
         }
     }

+ 2 - 4
Unity/Assets/Scripts/Core/Entity/Scene.cs

@@ -3,7 +3,7 @@
 namespace ET
 {
     [EnableMethod]
-    [DebuggerDisplay("ViewGoName,nq")]
+    [DebuggerDisplay("ViewName,nq")]
     public sealed class Scene: Entity
     {
         public int Zone
@@ -99,14 +99,12 @@ namespace ET
             }
         }
         
-#if ENABLE_CODES
-        protected override string ViewGoName
+        protected override string ViewName
         {
             get
             {
                 return $"{this.GetType().Name} ({this.SceneType})";    
             }
         }
-#endif
     }
 }

+ 1 - 1
Unity/Assets/Scripts/Core/Object/ComponentView.cs

@@ -1,4 +1,4 @@
-#if ENABLE_CODES
+#if ENABLE_VIEW
 using UnityEngine;
 
 namespace ET

+ 4 - 6
Unity/Assets/Scripts/Core/Object/Entity.cs

@@ -18,7 +18,7 @@ namespace ET
 
     public partial class Entity: DisposeObject
     {
-#if ENABLE_CODES
+#if ENABLE_VIEW
         private UnityEngine.GameObject viewGO;
 #endif
         
@@ -79,10 +79,10 @@ namespace ET
 
                 EventSystem.Instance.RegisterSystem(this, value);
                 
-#if ENABLE_CODES
+#if ENABLE_VIEW
                 if (value)
                 {
-                    this.viewGO = new UnityEngine.GameObject(this.ViewGoName);
+                    this.viewGO = new UnityEngine.GameObject(this.ViewName);
                     this.viewGO.AddComponent<ComponentView>().Component = this;
                     this.viewGO.transform.SetParent(this.Parent == null? 
                             UnityEngine.GameObject.Find("Global").transform : this.Parent.viewGO.transform);
@@ -95,15 +95,13 @@ namespace ET
             }
         }
         
-#if ENABLE_CODES
-        protected virtual string ViewGoName
+        protected virtual string ViewName
         {
             get
             {
                 return this.GetType().Name;    
             }
         }
-#endif
 
         [IgnoreDataMember]
         [BsonIgnore]

+ 59 - 9
Unity/Assets/Scripts/Editor/BuildEditor/BuildHelper.cs

@@ -15,26 +15,76 @@ namespace ET
         
 #if ENABLE_CODES
         [MenuItem("ET/ChangeDefine/Remove ENABLE_CODES")]
+        public static void RemoveEnableCodes()
+        {
+            EnableCodes(false);
+        }
 #else
         [MenuItem("ET/ChangeDefine/Add ENABLE_CODES")]
+        public static void AddEnableCodes()
+        {
+            EnableCodes(true);
+        }
 #endif
-        public static void EnableCodes()
+        private static void EnableCodes(bool enable)
         {
             string defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
             var ss = defines.Split(';').ToList();
-#if ENABLE_CODES
-            if (!ss.Contains("ENABLE_CODES"))
+            if (enable)
             {
-                return;
+                if (ss.Contains("ENABLE_CODES"))
+                {
+                    return;
+                }
+                ss.Add("ENABLE_CODES");
             }
-            ss.Remove("ENABLE_CODES");
-#else
-            if (ss.Contains("ENABLE_CODES"))
+            else
             {
-                return;
+                if (!ss.Contains("ENABLE_CODES"))
+                {
+                    return;
+                }
+                ss.Remove("ENABLE_CODES");
             }
-            ss.Add("ENABLE_CODES");
+            defines = string.Join(";", ss);
+            PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, defines);
+            AssetDatabase.SaveAssets();
+        }
+        
+#if ENABLE_VIEW
+        [MenuItem("ET/ChangeDefine/Remove ENABLE_VIEW")]
+        public static void RemoveEnableView()
+        {
+            EnableView(false);
+        }
+#else
+        [MenuItem("ET/ChangeDefine/Add ENABLE_VIEW")]
+        public static void AddEnableView()
+        {
+            EnableView(true);
+        }
 #endif
+        private static void EnableView(bool enable)
+        {
+            string defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
+            var ss = defines.Split(';').ToList();
+            if (enable)
+            {
+                if (ss.Contains("ENABLE_VIEW"))
+                {
+                    return;
+                }
+                ss.Add("ENABLE_VIEW");
+            }
+            else
+            {
+                if (!ss.Contains("ENABLE_VIEW"))
+                {
+                    return;
+                }
+                ss.Remove("ENABLE_VIEW");
+            }
+            
             defines = string.Join(";", ss);
             PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, defines);
             AssetDatabase.SaveAssets();

+ 1 - 1
Unity/Assets/Scripts/Editor/ComponentViewEditor/ComponentViewEditor.cs

@@ -1,4 +1,4 @@
-#if ENABLE_CODES
+#if ENABLE_VIEW
 using System;
 using System.Collections.Generic;
 using System.Reflection;

+ 1 - 1
Unity/Assets/Scripts/Editor/ComponentViewEditor/Tree/EntityTreeView.cs

@@ -1,4 +1,4 @@
-#if ENABLE_CODES
+#if ENABLE_VIEW
 using System.Collections.Generic;
 using UnityEditor;
 using UnityEditor.IMGUI.Controls;

+ 1 - 1
Unity/Assets/Scripts/Editor/ComponentViewEditor/Tree/EntityTreeViewItem.cs

@@ -1,4 +1,4 @@
-#if ENABLE_CODES
+#if ENABLE_VIEW
 
 using System;
 using System.Runtime.CompilerServices;

+ 1 - 1
Unity/Assets/Scripts/Editor/ComponentViewEditor/Tree/EntityTreeWindow.cs

@@ -1,4 +1,4 @@
-#if ENABLE_CODES
+#if ENABLE_VIEW
 using System;
 using UnityEditor;
 using UnityEditor.IMGUI.Controls;

+ 6 - 0
Unity/Assets/Scripts/Mono/Define.cs

@@ -22,6 +22,12 @@
         public static bool EnableCodes = false;
 #endif
 		
+#if ENABLE_VIEW
+		public static bool EnableView = true;
+#else
+		public static bool EnableView = false;
+#endif
+		
 		public static UnityEngine.Object LoadAssetAtPath(string s)
 		{
 #if UNITY_EDITOR	

+ 1 - 1
Unity/ProjectSettings/ProjectSettings.asset

@@ -847,7 +847,7 @@ PlayerSettings:
   scriptingDefineSymbols:
     Android: NETSTANDARD2_0;UNITY
     Server: NETSTANDARD2_0;UNITY
-    Standalone: NETSTANDARD2_0;UNITY
+    Standalone: NETSTANDARD2_0;UNITY;ENABLE_VIEW
     WebGL: NETSTANDARD2_0;UNITY
     iPhone: NETSTANDARD2_0;UNITY
   additionalCompilerArguments: {}