Просмотр исходного кода

修复了一些IL2CPP下的问题
Unit类上面有个mono层的bson标签,导致EventSystem扫描的时候报错

目前crash在 Game.Scene.AddComponent<CoroutineLockComponent>();中
crash在Entity.Create中,暂时没找到问题

tanghai 4 лет назад
Родитель
Сommit
f12ffba346
38 измененных файлов с 187 добавлено и 74 удалено
  1. 1 0
      Server/Model/Demo/Player.cs
  2. 3 5
      Unity/Assets/Editor/BuildEditor/BuildEditor.cs
  3. 13 1
      Unity/Assets/Editor/BuildEditor/BuildHelper.cs
  4. 3 3
      Unity/Assets/Editor/BuildEditor/ETBuildSettings.asset
  5. 1 1
      Unity/Assets/Mono/Define.cs
  6. 21 3
      Unity/Assets/Mono/ILRuntime/Generate/ET_CodeLoader_Binding.cs
  7. 21 0
      Unity/Assets/Mono/ILRuntime/Generate/UnityEngine_Input_Binding.cs
  8. 20 0
      Unity/Assets/Mono/ILRuntime/ILHelper.cs
  9. 0 4
      Unity/Assets/link.xml
  10. 2 1
      Unity/Codes/Hotfix/Demo/Unit/UnitComponent.cs
  11. 1 0
      Unity/Codes/Hotfix/Demo/Unit/UnitSystem.cs
  12. 2 0
      Unity/Codes/Hotfix/Module/Config/ConfigComponentSystem.cs
  13. 1 1
      Unity/Codes/Hotfix/Module/Message/SessionAcceptTimeoutComponentSystem.cs
  14. 11 2
      Unity/Codes/HotfixView/AppStart_Init.cs
  15. 1 0
      Unity/Codes/HotfixView/Demo/Config/ConfigComponent_SetConfigLoader_Awake.cs
  16. 1 0
      Unity/Codes/HotfixView/Demo/Global/GlobalComponentSystem.cs
  17. 2 0
      Unity/Codes/HotfixView/Demo/Opera/OperaComponentSystem.cs
  18. 1 0
      Unity/Codes/HotfixView/Demo/UI/UILoading/UILoadingComponentSystem.cs
  19. 1 0
      Unity/Codes/HotfixView/Demo/UI/UILobby/UILobbyComponentSystem.cs
  20. 1 0
      Unity/Codes/HotfixView/Demo/UI/UILogin/UILoginComponentSystem.cs
  21. 3 1
      Unity/Codes/HotfixView/Demo/UI/UILogin/UILoginEvent.cs
  22. 3 0
      Unity/Codes/HotfixView/Demo/Unit/AnimatorComponentSystem.cs
  23. 0 7
      Unity/Codes/HotfixView/Module/UI/UIComponentSystem.cs
  24. 1 0
      Unity/Codes/HotfixView/Module/UI/UIEventComponentSystem.cs
  25. 0 6
      Unity/Codes/Model/Core/Object/BaseAttribute.cs
  26. 18 5
      Unity/Codes/Model/Core/Object/Entity.cs
  27. 3 1
      Unity/Codes/Model/Core/Object/EventSystem.cs
  28. 1 1
      Unity/Codes/Model/Core/Object/IAwakeSystem.cs
  29. 1 2
      Unity/Codes/Model/Demo/Unit/Unit.cs
  30. 3 3
      Unity/Codes/Model/Module/CoroutineLock/CoroutineLock.cs
  31. 22 13
      Unity/Codes/Model/Module/CoroutineLock/CoroutineLockComponent.cs
  32. 6 1
      Unity/Codes/Model/Module/CoroutineLock/CoroutineLockQueueType.cs
  33. 10 10
      Unity/Codes/Model/Module/CoroutineLock/CoroutineLockType.cs
  34. 1 1
      Unity/Codes/Model/Module/Numeric/NumericComponent.cs
  35. 1 1
      Unity/Codes/Model/Module/Numeric/NumericWatcherComponent.cs
  36. 2 0
      Unity/Codes/ModelView/Demo/Camera/CameraComponent.cs
  37. 4 0
      Unity/Codes/ModelView/Demo/Entry.cs
  38. 1 1
      Unity/Codes/ModelView/Module/UI/UI.cs

+ 1 - 0
Server/Model/Demo/Player.cs

@@ -1,5 +1,6 @@
 namespace ET
 {
+	[ObjectSystem]
 	public class PlayerSystem : AwakeSystem<Player, string>
 	{
 		public override void Awake(Player self, string a)

+ 3 - 5
Unity/Assets/Editor/BuildEditor/BuildEditor.cs

@@ -49,9 +49,7 @@ namespace ET
 		[MenuItem("Tools/打包工具")]
 		public static void ShowWindow()
 		{
-			EditorWindow window = GetWindow<BuildEditor>(true, "打包工具");
-			window.minSize = new Vector2(420, 220);
-			window.maxSize = new Vector2(700, 400);
+			GetWindow(typeof (BuildEditor));
 		}
 
         private void OnEnable()
@@ -105,7 +103,7 @@ namespace ET
 			switch (buildType)
 			{
 				case BuildType.Development:
-					this.buildOptions = BuildOptions.Development | BuildOptions.AutoRunPlayer | BuildOptions.ConnectWithProfiler | BuildOptions.AllowDebugging;
+					this.buildOptions = BuildOptions.Development | BuildOptions.ConnectWithProfiler | BuildOptions.AllowDebugging;
 					break;
 				case BuildType.Release:
 					this.buildOptions = BuildOptions.None;
@@ -114,7 +112,7 @@ namespace ET
 
 			GUILayout.Space(5);
 
-			if (GUILayout.Button("开始打包", GUILayout.ExpandHeight(true)))
+			if (GUILayout.Button("开始打包"))
 			{
 				if (this.platformType == PlatformType.None)
 				{

+ 13 - 1
Unity/Assets/Editor/BuildEditor/BuildHelper.cs

@@ -1,6 +1,7 @@
 using System.IO;
 
 using UnityEditor;
+using UnityEngine;
 
 namespace ET
 {
@@ -20,7 +21,8 @@ namespace ET
         public static void Build(PlatformType type, BuildAssetBundleOptions buildAssetBundleOptions, BuildOptions buildOptions, bool isBuildExe, bool isContainAB, bool clearFolder)
         {
             BuildTarget buildTarget = BuildTarget.StandaloneWindows;
-            string exeName = "ET";
+            string programName = "ET";
+            string exeName = programName;
             switch (type)
             {
                 case PlatformType.PC:
@@ -72,6 +74,16 @@ namespace ET
                 BuildPipeline.BuildPlayer(levels, $"{relativeDirPrefix}/{exeName}", buildTarget, buildOptions);
                 UnityEngine.Debug.Log("完成exe打包");
             }
+            else
+            {
+                if (isContainAB && type == PlatformType.PC)
+                {
+                    string targetPath = Path.Combine(relativeDirPrefix, $"{programName}_Data/StreamingAssets/");
+                    FileHelper.CleanDirectory(targetPath);
+                    Debug.Log($"src dir: {fold}    target: {targetPath}");
+                    FileHelper.CopyDirectory(fold, targetPath);
+                }
+            }
         }
     }
 }

+ 3 - 3
Unity/Assets/Editor/BuildEditor/ETBuildSettings.asset

@@ -12,8 +12,8 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: b216745cd6e9bc94da5bdf9fe8aae6d1, type: 3}
   m_Name: ETBuildSettings
   m_EditorClassIdentifier: 
-  clearFolder: 0
-  isBuildExe: 1
+  clearFolder: 1
+  isBuildExe: 0
   isContainAB: 1
-  buildType: 1
+  buildType: 0
   buildAssetBundleOptions: 0

+ 1 - 1
Unity/Assets/Mono/Define.cs

@@ -5,7 +5,7 @@
 		public const string BuildOutputDir = "./Temp/Bin/Debug";
 
 		// 1 mono模式 2 ILRuntime模式 3 mono热重载模式
-		public static int CodeMode = 3;
+		public static int CodeMode = 2;
 		public const int CodeMode_Mono = 1;
 		public const int CodeMode_ILRuntime = 2;
 		public const int CodeMode_Reload = 3;

+ 21 - 3
Unity/Assets/Mono/ILRuntime/Generate/ET_CodeLoader_Binding.cs

@@ -24,8 +24,11 @@ namespace ILRuntime.Runtime.Generated
             Type[] args;
             Type type = typeof(ET.CodeLoader);
             args = new Type[]{};
-            method = type.GetMethod("GetHotfixTypes", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, GetHotfixTypes_0);
+            method = type.GetMethod("GetTypes", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, GetTypes_0);
+            args = new Type[]{};
+            method = type.GetMethod("LoadHotfix", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, LoadHotfix_1);
 
             field = type.GetField("Instance", flag);
             app.RegisterCLRFieldGetter(field, get_Instance_0);
@@ -48,7 +51,7 @@ namespace ILRuntime.Runtime.Generated
         }
 
 
-        static StackObject* GetHotfixTypes_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        static StackObject* GetTypes_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
         {
             ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
             StackObject* ptr_of_this_method;
@@ -63,6 +66,21 @@ namespace ILRuntime.Runtime.Generated
             return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
         }
 
+        static StackObject* LoadHotfix_1(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        {
+            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
+            StackObject* ptr_of_this_method;
+            StackObject* __ret = ILIntepreter.Minus(__esp, 1);
+
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
+            ET.CodeLoader instance_of_this_method = (ET.CodeLoader)typeof(ET.CodeLoader).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
+            __intp.Free(ptr_of_this_method);
+
+            instance_of_this_method.LoadHotfix();
+
+            return __ret;
+        }
+
 
         static object get_Instance_0(ref object o)
         {

+ 21 - 0
Unity/Assets/Mono/ILRuntime/Generate/UnityEngine_Input_Binding.cs

@@ -28,6 +28,9 @@ namespace ILRuntime.Runtime.Generated
             args = new Type[]{};
             method = type.GetMethod("get_mousePosition", flag, null, args, null);
             app.RegisterCLRMethodRedirection(method, get_mousePosition_1);
+            args = new Type[]{typeof(UnityEngine.KeyCode)};
+            method = type.GetMethod("GetKeyDown", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, GetKeyDown_2);
 
 
         }
@@ -61,6 +64,24 @@ namespace ILRuntime.Runtime.Generated
             return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
         }
 
+        static StackObject* GetKeyDown_2(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        {
+            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
+            StackObject* ptr_of_this_method;
+            StackObject* __ret = ILIntepreter.Minus(__esp, 1);
+
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
+            UnityEngine.KeyCode @key = (UnityEngine.KeyCode)typeof(UnityEngine.KeyCode).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)20);
+            __intp.Free(ptr_of_this_method);
+
+
+            var result_of_this_method = UnityEngine.Input.GetKeyDown(@key);
+
+            __ret->ObjectType = ObjectTypes.Integer;
+            __ret->Value = result_of_this_method ? 1 : 0;
+            return __ret + 1;
+        }
+
 
 
     }

+ 20 - 0
Unity/Assets/Mono/ILRuntime/ILHelper.cs

@@ -15,8 +15,28 @@ namespace ET
 {
     public static class ILHelper
     {
+        public static List<Type> list = new List<Type>();
+
         public static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain appdomain)
         {
+            list.Add(typeof(Dictionary<int, ILTypeInstance>));
+            list.Add(typeof(Dictionary<int, int>));
+            list.Add(typeof(Dictionary<object, object>));
+            list.Add(typeof(Dictionary<int, object>));
+            list.Add(typeof(Dictionary<long, object>));
+            list.Add(typeof(Dictionary<long, int>));
+            list.Add(typeof(Dictionary<int, long>));
+            list.Add(typeof(Dictionary<string, long>));
+            list.Add(typeof(Dictionary<string, int>));
+            list.Add(typeof(Dictionary<string, object>));
+            list.Add(typeof(List<int>));
+            list.Add(typeof(List<long>));
+            list.Add(typeof(List<string>));
+            list.Add(typeof(List<object>));
+            list.Add(typeof(ETTask<int>));
+            list.Add(typeof(ETTask<long>));
+            list.Add(typeof(ETTask<string>));
+            list.Add(typeof(ETTask<object>));
             
             // 注册重定向函数
 

+ 0 - 4
Unity/Assets/link.xml

@@ -1,8 +1,4 @@
 <linker>
-    <assembly fullname="Unity.Hotfix" preserve="all"/>
-    <assembly fullname="Unity.HotfixView" preserve="all"/>
-    <assembly fullname="Unity.Model" preserve="all"/>
-    <assembly fullname="Unity.ModelView" preserve="all"/>
     <assembly fullname="Unity.Mono" preserve="all"/>
     <assembly fullname="Unity.ThirdParty" preserve="all"/>
     <assembly fullname="UnityEngine" preserve="all"/>

+ 2 - 1
Unity/Codes/Hotfix/Demo/Unit/UnitComponent.cs

@@ -3,7 +3,7 @@ using System.Linq;
 
 namespace ET
 {
-	
+	[ObjectSystem]
 	public class UnitComponentAwakeSystem : AwakeSystem<UnitComponent>
 	{
 		public override void Awake(UnitComponent self)
@@ -11,6 +11,7 @@ namespace ET
 		}
 	}
 	
+	[ObjectSystem]
 	public class UnitComponentDestroySystem : DestroySystem<UnitComponent>
 	{
 		public override void Destroy(UnitComponent self)

+ 1 - 0
Unity/Codes/Hotfix/Demo/Unit/UnitSystem.cs

@@ -1,5 +1,6 @@
 namespace ET
 {
+    [ObjectSystem]
     public class UnitSystem: AwakeSystem<Unit, int>
     {
         public override void Awake(Unit self, int configId)

+ 2 - 0
Unity/Codes/Hotfix/Module/Config/ConfigComponentSystem.cs

@@ -4,6 +4,7 @@ using System.Threading.Tasks;
 
 namespace ET
 {
+	[ObjectSystem]
     public class ConfigAwakeSystem : AwakeSystem<ConfigComponent>
     {
         public override void Awake(ConfigComponent self)
@@ -12,6 +13,7 @@ namespace ET
         }
     }
     
+    [ObjectSystem]
     public class ConfigDestroySystem : DestroySystem<ConfigComponent>
     {
 	    public override void Destroy(ConfigComponent self)

+ 1 - 1
Unity/Codes/Hotfix/Module/Message/SessionAcceptTimeoutComponentSystem.cs

@@ -1,4 +1,4 @@
-namespace ET
+namespace ET
 {
     [ObjectSystem]
     public class SessionAcceptTimeoutComponentAwakeSystem: AwakeSystem<SessionAcceptTimeoutComponent>

+ 11 - 2
Unity/Codes/HotfixView/AppStart_Init.cs

@@ -4,30 +4,39 @@ namespace ET
     {
         protected override async ETTask Run(EventType.AppStart args)
         {
+            Log.Info($"11111111111111111111111111111111111111111111113");
             Game.Scene.AddComponent<TimerComponent>();
+            Log.Info($"1111111111111111111111111111111111111111111111311");
             Game.Scene.AddComponent<CoroutineLockComponent>();
+            Log.Info($"1111111111111111111111111111111111111111111111312");
 
             // 加载配置
             Game.Scene.AddComponent<ResourcesComponent>();
+            Log.Info($"111111111111111111111111111111111111111111111131");
             ResourcesComponent.Instance.LoadBundle("config.unity3d");
+            Log.Info($"111111111111111111111111111111111111111111111132");
             Game.Scene.AddComponent<ConfigComponent>();
             ConfigComponent.Instance.Load();
+            Log.Info($"111111111111111111111111111111111111111111111133");
             ResourcesComponent.Instance.UnloadBundle("config.unity3d");
+            Log.Info($"111111111111111111111111111111111111111111111134");
             
+            Log.Info($"11111111111111111111111111111111111111111111114");
             Game.Scene.AddComponent<OpcodeTypeComponent>();
             Game.Scene.AddComponent<MessageDispatcherComponent>();
             
             Game.Scene.AddComponent<NetThreadComponent>();
             Game.Scene.AddComponent<SessionStreamDispatcher>();
-
+            Log.Info($"11111111111111111111111111111111111111111111115");
             Game.Scene.AddComponent<ZoneSceneManagerComponent>();
             
             Game.Scene.AddComponent<GlobalComponent>();
 
             Game.Scene.AddComponent<AIDispatcherComponent>();
-
+            Log.Info($"11111111111111111111111111111111111111111111116");
             ResourcesComponent.Instance.LoadBundle("unit.unity3d");
             Scene zoneScene = await SceneFactory.CreateZoneScene(1, "Game", Game.Scene);
+            Log.Info($"11111111111111111111111111111111111111111111117");
             await Game.EventSystem.Publish(new EventType.AppStartInitFinish() { ZoneScene = zoneScene });
         }
     }

+ 1 - 0
Unity/Codes/HotfixView/Demo/Config/ConfigComponent_SetConfigLoader_Awake.cs

@@ -1,5 +1,6 @@
 namespace ET
 {
+    [ObjectSystem]
     public class ConfigComponent_SetConfigLoader_Awake: AwakeSystem<ConfigComponent>
     {
         public override void Awake(ConfigComponent self)

+ 1 - 0
Unity/Codes/HotfixView/Demo/Global/GlobalComponentSystem.cs

@@ -2,6 +2,7 @@ using UnityEngine;
 
 namespace ET
 {
+    [ObjectSystem]
     public class GlobalComponentAwakeSystem: AwakeSystem<GlobalComponent>
     {
         public override void Awake(GlobalComponent self)

+ 2 - 0
Unity/Codes/HotfixView/Demo/Opera/OperaComponentSystem.cs

@@ -3,6 +3,7 @@ using UnityEngine;
 
 namespace ET
 {
+    [ObjectSystem]
     public class OperaComponentAwakeSystem : AwakeSystem<OperaComponent>
     {
         public override void Awake(OperaComponent self)
@@ -11,6 +12,7 @@ namespace ET
         }
     }
 
+    [ObjectSystem]
     public class OperaComponentUpdateSystem : UpdateSystem<OperaComponent>
     {
         public override void Update(OperaComponent self)

+ 1 - 0
Unity/Codes/HotfixView/Demo/UI/UILoading/UILoadingComponentSystem.cs

@@ -3,6 +3,7 @@ using UnityEngine.UI;
 
 namespace ET
 {
+    [ObjectSystem]
     public class UiLoadingComponentAwakeSystem : AwakeSystem<UILoadingComponent>
     {
         public override void Awake(UILoadingComponent self)

+ 1 - 0
Unity/Codes/HotfixView/Demo/UI/UILobby/UILobbyComponentSystem.cs

@@ -3,6 +3,7 @@ using UnityEngine.UI;
 
 namespace ET
 {
+    [ObjectSystem]
     public class UILobbyComponentAwakeSystem: AwakeSystem<UILobbyComponent>
     {
         public override void Awake(UILobbyComponent self)

+ 1 - 0
Unity/Codes/HotfixView/Demo/UI/UILogin/UILoginComponentSystem.cs

@@ -6,6 +6,7 @@ using UnityEngine.UI;
 
 namespace ET
 {
+	[ObjectSystem]
 	public class UILoginComponentAwakeSystem : AwakeSystem<UILoginComponent>
 	{
 		public override void Awake(UILoginComponent self)

+ 3 - 1
Unity/Codes/HotfixView/Demo/UI/UILogin/UILoginEvent.cs

@@ -8,11 +8,13 @@ namespace ET
     {
         public override async ETTask<UI> OnCreate(UIComponent uiComponent)
         {
+            Log.Info($"11111111111111111111111111111111111111111111117");
             await ResourcesComponent.Instance.LoadBundleAsync(UIType.UILogin.StringToAB());
+            Log.Info($"11111111111111111111111111111111111111111111118");
             GameObject bundleGameObject = (GameObject) ResourcesComponent.Instance.GetAsset(UIType.UILogin.StringToAB(), UIType.UILogin);
             GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject);
             UI ui = uiComponent.AddChild<UI, string, GameObject>(UIType.UILogin, gameObject);
-
+            Log.Info($"11111111111111111111111111111111111111111111119");
             ui.AddComponent<UILoginComponent>();
             return ui;
         }

+ 3 - 0
Unity/Codes/HotfixView/Demo/Unit/AnimatorComponentSystem.cs

@@ -3,6 +3,7 @@ using UnityEngine;
 
 namespace ET
 {
+	[ObjectSystem]
 	public class AnimatorComponentAwakeSystem : AwakeSystem<AnimatorComponent>
 	{
 		public override void Awake(AnimatorComponent self)
@@ -11,6 +12,7 @@ namespace ET
 		}
 	}
 
+	[ObjectSystem]
 	public class AnimatorComponentUpdateSystem : UpdateSystem<AnimatorComponent>
 	{
 		public override void Update(AnimatorComponent self)
@@ -19,6 +21,7 @@ namespace ET
 		}
 	}
 	
+	[ObjectSystem]
 	public class AnimatorComponentDestroySystem : DestroySystem<AnimatorComponent>
 	{
 		public override void Destroy(AnimatorComponent self)

+ 0 - 7
Unity/Codes/HotfixView/Module/UI/UIComponentSystem.cs

@@ -2,13 +2,6 @@
 
 namespace ET
 {
-	public class UIComponentAwakeSystem : AwakeSystem<UIComponent>
-	{
-		public override void Awake(UIComponent self)
-		{
-		}
-	}
-	
 	/// <summary>
 	/// 管理Scene上的UI
 	/// </summary>

+ 1 - 0
Unity/Codes/HotfixView/Module/UI/UIEventComponentSystem.cs

@@ -4,6 +4,7 @@ using UnityEngine;
 
 namespace ET
 {
+	[ObjectSystem]
 	public class UIEventComponentAwakeSystem : AwakeSystem<UIEventComponent>
 	{
 		public override void Awake(UIEventComponent self)

+ 0 - 6
Unity/Codes/Model/Core/Object/BaseAttribute.cs

@@ -5,11 +5,5 @@ namespace ET
 	[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
 	public class BaseAttribute: Attribute
 	{
-		public Type AttributeType { get; }
-
-		public BaseAttribute()
-		{
-			this.AttributeType = this.GetType();
-		}
 	}
 }

+ 18 - 5
Unity/Codes/Model/Core/Object/Entity.cs

@@ -15,6 +15,9 @@ namespace ET
         IsCreate = 1 << 3,
     }
 
+#if NOT_UNITY
+    [BsonIgnoreExtraElements]
+#endif
     public partial class Entity: DisposeObject
     {
         [IgnoreDataMember]
@@ -676,15 +679,21 @@ namespace ET
             Entity component;
             if (isFromPool)
             {
-                component = (Entity)ObjectPool.Instance.Fetch(type);
+                component = ObjectPool.Instance.Fetch(type) as Entity;
             }
             else
             {
-                component = (Entity)Activator.CreateInstance(type);
+                Log.Info($"1111111111111111111111111111111111111111111111311a22b2g1 : {type.Name}");
+                object obj = Activator.CreateInstance(type);
+                Log.Info($"1111111111111111111111111111111111111111111111311a22b2g1a : {type.Name}");
+                component = obj as Entity;
+                Log.Info($"1111111111111111111111111111111111111111111111311a22b2g2 : {type.Name}");
             }
             component.IsFromPool = isFromPool;
+            Log.Info($"1111111111111111111111111111111111111111111111311a22b2g3 : {type.Name}");
             component.IsCreate = true;
             component.Id = 0;
+            Log.Info($"1111111111111111111111111111111111111111111111311a22b2g4 : {type.Name}");
             return component;
         }
 
@@ -835,14 +844,18 @@ namespace ET
             return component;
         }
 
-        public T AddChildWithId<T>(long id, bool isFromPool = false) where T : Entity
+        public T AddChildWithId<T>(long id, bool isFromPool = false) where T : Entity, new()
         {
+            Log.Info($"1111111111111111111111111111111111111111111111311a22b1");
             Type type = typeof (T);
-            T component = (T) Entity.Create(type, isFromPool);
+            Log.Info($"1111111111111111111111111111111111111111111111311a22b2");
+            T component = Entity.Create(type, isFromPool) as T;
+            Log.Info($"1111111111111111111111111111111111111111111111311a22b3");
             component.Id = id;
             component.Parent = this;
-
+            Log.Info($"1111111111111111111111111111111111111111111111311a22b4");
             EventSystem.Instance.Awake(component);
+            Log.Info($"1111111111111111111111111111111111111111111111311a22b5");
             return component;
         }
 

+ 3 - 1
Unity/Codes/Model/Core/Object/EventSystem.cs

@@ -120,7 +120,7 @@ namespace ET
             }
 
             this.types.Clear();
-
+            Log.Info($"11111111111111111111111111111111111111111111111a1");
             List<Type> baseAttributeTypes = GetBaseAttributes(addTypes);
             foreach (Type baseAttributeType in baseAttributeTypes)
             {
@@ -141,6 +141,7 @@ namespace ET
                 }
             }
 
+            Log.Info($"11111111111111111111111111111111111111111111111a3");
             this.typeSystems = new TypeSystems();
 
             foreach (Type type in this.GetTypes(typeof (ObjectSystemAttribute)))
@@ -154,6 +155,7 @@ namespace ET
                 }
             }
 
+            Log.Info($"11111111111111111111111111111111111111111111111a4");
             this.allEvents.Clear();
             foreach (Type type in types[typeof (EventAttribute)])
             {

+ 1 - 1
Unity/Codes/Model/Core/Object/IAwakeSystem.cs

@@ -47,7 +47,7 @@ namespace ET
 
         public abstract void Awake(T self);
     }
-
+    
     [ObjectSystem]
     public abstract class AwakeSystem<T, A> : IAwakeSystem<A>
     {

+ 1 - 2
Unity/Codes/Model/Demo/Unit/Unit.cs

@@ -4,8 +4,7 @@ using UnityEngine;
 
 namespace ET
 {
-    [BsonIgnoreExtraElements]
-    public sealed class Unit: Entity
+    public class Unit: Entity
     {
         public int ConfigId; //配置表id
 

+ 3 - 3
Unity/Codes/Model/Module/CoroutineLock/CoroutineLock.cs

@@ -3,9 +3,9 @@ using System;
 namespace ET
 {
     [ObjectSystem]
-    public class CoroutineLockAwakeSystem: AwakeSystem<CoroutineLock, CoroutineLockType, long, int>
+    public class CoroutineLockAwakeSystem: AwakeSystem<CoroutineLock, int, long, int>
     {
-        public override void Awake(CoroutineLock self, CoroutineLockType type, long k, int count)
+        public override void Awake(CoroutineLock self, int type, long k, int count)
         {
             self.coroutineLockType = type;
             self.key = k;
@@ -35,7 +35,7 @@ namespace ET
     
     public class CoroutineLock: Entity
     {
-        public CoroutineLockType coroutineLockType;
+        public int coroutineLockType;
         public long key;
         public int level;
     }

+ 22 - 13
Unity/Codes/Model/Module/CoroutineLock/CoroutineLockComponent.cs

@@ -7,11 +7,20 @@ namespace ET
     {
         public override void Awake(CoroutineLockComponent self)
         {
+            Log.Info($"1111111111111111111111111111111111111111111111311a1");
             CoroutineLockComponent.Instance = self;
-            for (int i = 0; i < self.list.Capacity; ++i)
+            
+            self.list = new List<CoroutineLockQueueType>(CoroutineLockType.Max);
+            Log.Info($"1111111111111111111111111111111111111111111111311a2");
+            for (int i = 0; i < CoroutineLockType.Max; ++i)
             {
-                self.list.Add(self.AddChildWithId<CoroutineLockQueueType>(++self.idGenerator));
+                Log.Info($"1111111111111111111111111111111111111111111111311a22 {i}");
+                CoroutineLockQueueType coroutineLockQueueType = self.AddChildWithId<CoroutineLockQueueType>(++self.idGenerator);
+                Log.Info($"1111111111111111111111111111111111111111111111311a23 {i}");
+                self.list.Add(coroutineLockQueueType);
+                Log.Info($"1111111111111111111111111111111111111111111111311a24 {i}");
             }
+            Log.Info($"1111111111111111111111111111111111111111111111311a3");
         }
     }
 
@@ -40,7 +49,7 @@ namespace ET
             // 循环过程中会有对象继续加入队列
             while(self.nextFrameRun.Count > 0)
             {
-                (CoroutineLockType coroutineLockType, long key, int count) = self.nextFrameRun.Dequeue();
+                (int coroutineLockType, long key, int count) = self.nextFrameRun.Dequeue();
                 self.Notify(coroutineLockType, key, count);
             }
         }
@@ -102,7 +111,7 @@ namespace ET
 
     public static class CoroutineLockComponentSystem
     {
-        public static void RunNextCoroutine(this CoroutineLockComponent self, CoroutineLockType coroutineLockType, long key, int level)
+        public static void RunNextCoroutine(this CoroutineLockComponent self, int coroutineLockType, long key, int level)
         {
             // 一个协程队列一帧处理超过100个,说明比较多了,打个warning,检查一下是否够正常
             if (level == 100)
@@ -121,9 +130,9 @@ namespace ET
             }
         }
 
-        public static async ETTask<CoroutineLock> Wait(this CoroutineLockComponent self, CoroutineLockType coroutineLockType, long key, int time = 60000)
+        public static async ETTask<CoroutineLock> Wait(this CoroutineLockComponent self, int coroutineLockType, long key, int time = 60000)
         {
-            CoroutineLockQueueType coroutineLockQueueType = self.list[(int) coroutineLockType];
+            CoroutineLockQueueType coroutineLockQueueType = self.list[coroutineLockType];
    
             if (!coroutineLockQueueType.TryGetValue(key, out CoroutineLockQueue queue))
             {
@@ -137,9 +146,9 @@ namespace ET
             return await tcs;
         }
 
-        private static CoroutineLock CreateCoroutineLock(this CoroutineLockComponent self, CoroutineLockType coroutineLockType, long key, int time, int level)
+        private static CoroutineLock CreateCoroutineLock(this CoroutineLockComponent self, int coroutineLockType, long key, int time, int level)
         {
-            CoroutineLock coroutineLock = self.AddChildWithId<CoroutineLock, CoroutineLockType, long, int>(++self.idGenerator, coroutineLockType, key, level, true);
+            CoroutineLock coroutineLock = self.AddChildWithId<CoroutineLock, int, long, int>(++self.idGenerator, coroutineLockType, key, level, true);
             if (time > 0)
             {
                 self.AddTimer(TimeHelper.ClientFrameTime() + time, coroutineLock);
@@ -147,9 +156,9 @@ namespace ET
             return coroutineLock;
         }
 
-        public static void Notify(this CoroutineLockComponent self, CoroutineLockType coroutineLockType, long key, int level)
+        public static void Notify(this CoroutineLockComponent self, int coroutineLockType, long key, int level)
         {
-            CoroutineLockQueueType coroutineLockQueueType = self.list[(int) coroutineLockType];
+            CoroutineLockQueueType coroutineLockQueueType = self.list[coroutineLockType];
             if (!coroutineLockQueueType.TryGetValue(key, out CoroutineLockQueue queue))
             {
                 return;
@@ -169,9 +178,9 @@ namespace ET
     public class CoroutineLockComponent: Entity
     {
         public static CoroutineLockComponent Instance;
-        
-        public List<CoroutineLockQueueType> list = new List<CoroutineLockQueueType>((int) CoroutineLockType.Max);
-        public Queue<(CoroutineLockType, long, int)> nextFrameRun = new Queue<(CoroutineLockType, long, int)>();
+
+        public List<CoroutineLockQueueType> list;
+        public Queue<(int, long, int)> nextFrameRun = new Queue<(int, long, int)>();
         public MultiMap<long, CoroutineLockTimer> timers = new MultiMap<long, CoroutineLockTimer>();
         public Queue<long> timeOutIds = new Queue<long>();
         public Queue<CoroutineLockTimer> timerOutTimer = new Queue<CoroutineLockTimer>();

+ 6 - 1
Unity/Codes/Model/Module/CoroutineLock/CoroutineLockQueueType.cs

@@ -8,6 +8,11 @@ namespace ET
     {
         public override void Awake(CoroutineLockQueueType self)
         {
+            if (self.dictionary == null)
+            {
+                self.dictionary = new Dictionary<long, CoroutineLockQueue>();
+            }
+
             self.dictionary.Clear();
         }
     }
@@ -23,7 +28,7 @@ namespace ET
     
     public class CoroutineLockQueueType: Entity
     {
-        public Dictionary<long, CoroutineLockQueue> dictionary = new Dictionary<long, CoroutineLockQueue>();
+        public Dictionary<long, CoroutineLockQueue> dictionary;
 
         public bool TryGetValue(long key, out CoroutineLockQueue value)
         {

+ 10 - 10
Unity/Codes/Model/Module/CoroutineLock/CoroutineLockType.cs

@@ -1,16 +1,16 @@
 namespace ET
 {
-    public enum CoroutineLockType
+    public static class CoroutineLockType
     {
-        None = 0,
-        Location,                  // location进程上使用
-        ActorLocationSender,       // ActorLocationSender中队列消息 
-        Mailbox,                   // Mailbox中队列
-        UnitId,                    // Map服务器上线下线时使用
-        DB,
-        Resources,
-        ResourcesLoader,
+        public const int None = 0;
+        public const int Location = 1;                  // location进程上使用
+        public const int ActorLocationSender = 2;       // ActorLocationSender中队列消息 
+        public const int Mailbox = 3;                   // Mailbox中队列
+        public const int UnitId = 4;                    // Map服务器上线下线时使用
+        public const int DB = 5;
+        public const int Resources = 6;
+        public const int ResourcesLoader = 7;
 
-        Max, // 这个必须在最后
+        public const int Max = 100; // 这个必须最大
     }
 }

+ 1 - 1
Unity/Codes/Model/Module/Numeric/NumericComponent.cs

@@ -13,7 +13,7 @@ namespace ET
 		}
 	}
 	
-	
+	[ObjectSystem]
 	public class NumericComponentAwakeSystem : AwakeSystem<NumericComponent>
 	{
 		public override void Awake(NumericComponent self)

+ 1 - 1
Unity/Codes/Model/Module/Numeric/NumericWatcherComponent.cs

@@ -3,7 +3,7 @@ using System.Collections.Generic;
 
 namespace ET
 {
-	
+	[ObjectSystem]
 	public class NumericWatcherComponentAwakeSystem : AwakeSystem<NumericWatcherComponent>
 	{
 		public override void Awake(NumericWatcherComponent self)

+ 2 - 0
Unity/Codes/ModelView/Demo/Camera/CameraComponent.cs

@@ -2,6 +2,7 @@
 
 namespace ET
 {
+	[ObjectSystem]
 	public class CameraComponentAwakeSystem : AwakeSystem<CameraComponent>
 	{
 		public override void Awake(CameraComponent self)
@@ -10,6 +11,7 @@ namespace ET
 		}
 	}
 
+	[ObjectSystem]
 	public class CameraComponentLateUpdateSystem : LateUpdateSystem<CameraComponent>
 	{
 		public override void LateUpdate(CameraComponent self)

+ 4 - 0
Unity/Codes/ModelView/Demo/Entry.cs

@@ -12,8 +12,12 @@ namespace ET
 				CodeLoader.Instance.LateUpdate += Game.LateUpdate;
 				CodeLoader.Instance.OnApplicationQuit += Game.Close;
 				
+				Log.Info($"11111111111111111111111111111111111111111111111");
+				
 				Game.EventSystem.Add(CodeLoader.Instance.GetTypes());
 
+				Log.Info($"11111111111111111111111111111111111111111111112");
+				
 				Game.EventSystem.Publish(new EventType.AppStart()).Coroutine();
 			}
 			catch (Exception e)

+ 1 - 1
Unity/Codes/ModelView/Module/UI/UI.cs

@@ -4,7 +4,7 @@ using UnityEngine;
 
 namespace ET
 {
-	
+	[ObjectSystem]
 	public class UIAwakeSystem : AwakeSystem<UI, string, GameObject>
 	{
 		public override void Awake(UI self, string name, GameObject gameObject)