فهرست منبع

IL2CPP打包运行成功,ILRuntime是master版本,开启了寄存器模式,出现问题主要三个原因:
1.代码裁剪 MongoBson的Attribute等等
2.范型 ETTask<AssetsBundle>
3.委托注册 加载AB包里面的Action<AsyncOperation>

tanghai 4 سال پیش
والد
کامیت
663e9e0042

+ 16 - 16
Unity/Assets/Mono/ILRuntime/Generate/ET_Log_Binding.cs

@@ -34,12 +34,12 @@ namespace ILRuntime.Runtime.Generated
             args = new Type[]{typeof(System.String)};
             method = type.GetMethod("Warning", flag, null, args, null);
             app.RegisterCLRMethodRedirection(method, Warning_3);
-            args = new Type[]{};
-            method = type.GetMethod("get_ILog", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, get_ILog_4);
             args = new Type[]{typeof(System.String)};
             method = type.GetMethod("Debug", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, Debug_5);
+            app.RegisterCLRMethodRedirection(method, Debug_4);
+            args = new Type[]{};
+            method = type.GetMethod("get_ILog", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, get_ILog_5);
 
 
         }
@@ -109,18 +109,7 @@ namespace ILRuntime.Runtime.Generated
             return __ret;
         }
 
-        static StackObject* get_ILog_4(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
-        {
-            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
-            StackObject* __ret = ILIntepreter.Minus(__esp, 0);
-
-
-            var result_of_this_method = ET.Log.ILog;
-
-            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
-        }
-
-        static StackObject* Debug_5(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        static StackObject* Debug_4(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
         {
             ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
             StackObject* ptr_of_this_method;
@@ -136,6 +125,17 @@ namespace ILRuntime.Runtime.Generated
             return __ret;
         }
 
+        static StackObject* get_ILog_5(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        {
+            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
+            StackObject* __ret = ILIntepreter.Minus(__esp, 0);
+
+
+            var result_of_this_method = ET.Log.ILog;
+
+            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
+        }
+
 
 
     }

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

@@ -29,14 +29,20 @@ namespace ET
             list.Add(typeof(Dictionary<string, long>));
             list.Add(typeof(Dictionary<string, int>));
             list.Add(typeof(Dictionary<string, object>));
+            list.Add(typeof(List<ILTypeInstance>));
             list.Add(typeof(List<int>));
             list.Add(typeof(List<long>));
             list.Add(typeof(List<string>));
             list.Add(typeof(List<object>));
+            list.Add(typeof(ListComponent<ILTypeInstance>));
             list.Add(typeof(ETTask<int>));
             list.Add(typeof(ETTask<long>));
             list.Add(typeof(ETTask<string>));
             list.Add(typeof(ETTask<object>));
+            list.Add(typeof(ETTask<AssetBundle>));
+            list.Add(typeof(ETTask<UnityEngine.Object[]>));
+            list.Add(typeof(ListComponent<ETTask>));
+            list.Add(typeof(ListComponent<Vector3>));
             
             // 注册重定向函数
 
@@ -50,6 +56,7 @@ namespace ET
             appdomain.DelegateManager.RegisterMethodDelegate<long, MemoryStream>();
             appdomain.DelegateManager.RegisterMethodDelegate<long, IPEndPoint>();
             appdomain.DelegateManager.RegisterMethodDelegate<ILTypeInstance>();
+            appdomain.DelegateManager.RegisterMethodDelegate<AsyncOperation>();
             
             
             appdomain.DelegateManager.RegisterFunctionDelegate<UnityEngine.Events.UnityAction>();

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

@@ -4,39 +4,28 @@ 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 });
         }
     }

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

@@ -8,13 +8,10 @@ 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;
         }

+ 1 - 12
Unity/Codes/Model/Core/Object/Entity.cs

@@ -680,17 +680,11 @@ namespace ET
             }
             else
             {
-                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 = Activator.CreateInstance(type) as Entity;
             }
             component.IsFromPool = isFromPool;
-            Log.Info($"1111111111111111111111111111111111111111111111311a22b2g3 : {type.Name}");
             component.IsCreate = true;
             component.Id = 0;
-            Log.Info($"1111111111111111111111111111111111111111111111311a22b2g4 : {type.Name}");
             return component;
         }
 
@@ -843,16 +837,11 @@ namespace ET
 
         public T AddChildWithId<T>(long id, bool isFromPool = false) where T : Entity, new()
         {
-            Log.Info($"1111111111111111111111111111111111111111111111311a22b1");
             Type type = typeof (T);
-            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;
         }
 

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

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

+ 0 - 8
Unity/Codes/Model/Module/CoroutineLock/CoroutineLockComponent.cs

@@ -7,20 +7,14 @@ namespace ET
     {
         public override void Awake(CoroutineLockComponent self)
         {
-            Log.Info($"1111111111111111111111111111111111111111111111311a1");
             CoroutineLockComponent.Instance = self;
             
             self.list = new List<CoroutineLockQueueType>(CoroutineLockType.Max);
-            Log.Info($"1111111111111111111111111111111111111111111111311a2");
             for (int i = 0; i < CoroutineLockType.Max; ++i)
             {
-                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");
         }
     }
 
@@ -139,10 +133,8 @@ namespace ET
                 coroutineLockQueueType.Add(key, self.AddChildWithId<CoroutineLockQueue>(++self.idGenerator, true));
                 return self.CreateCoroutineLock(coroutineLockType, key, time, 1);
             }
-
             ETTask<CoroutineLock> tcs = ETTask<CoroutineLock>.Create(true);
             queue.Add(tcs, time);
-            
             return await tcs;
         }
 

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

@@ -12,11 +12,9 @@ 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();
 			}

+ 3 - 8
Unity/Codes/ModelView/Demo/Resource/ResourcesComponent.cs

@@ -465,6 +465,7 @@ namespace ET
             {
                 async ETTask LoadDependency(string dependency, List<ABInfo> abInfosList)
                 {
+                    Log.Debug($"111111111111111111111111111111111111ggggg1");
                     CoroutineLock coroutineLock = null;
                     try
                     {
@@ -486,11 +487,11 @@ namespace ET
                 // LoadFromFileAsync部分可以并发加载
                 using (ListComponent<ETTask> tasks = ListComponent<ETTask>.Create())
                 {
+                    Log.Debug($"111111111111111111111111111111111111ggggga1");
                     foreach (string dependency in dependencies)
                     {
                         tasks.Add(LoadDependency(dependency, abInfos.List));
                     }
-
                     await ETTaskHelper.WaitAll(tasks.List);
 
                     // ab包从硬盘加载完成,可以再并发加载all assets
@@ -499,7 +500,6 @@ namespace ET
                     {
                         tasks.Add(LoadOneBundleAllAssets(abInfo));
                     }
-
                     await ETTaskHelper.WaitAll(tasks.List);
                 }
             }
@@ -515,7 +515,7 @@ namespace ET
                 //Log.Debug($"---------------load one bundle {assetBundleName} refcount: {abInfo.RefCount}");
                 return null;
             }
-
+            Log.Debug($"111111111111111111111111111111111111gggggdddddd1");
             string p = "";
             AssetBundle assetBundle = null;
 
@@ -548,13 +548,11 @@ namespace ET
                     return abInfo;
                 }
             }
-
             p = Path.Combine(PathHelper.AppHotfixResPath, assetBundleName);
             if (!File.Exists(p))
             {
                 p = Path.Combine(PathHelper.AppResPath, assetBundleName);
             }
-
             Log.Debug("Async load bundle BundleName : " + p);
 
             // if (!File.Exists(p))
@@ -562,16 +560,13 @@ namespace ET
             //     Log.Error("Async load bundle not exist! BundleName : " + p);
             //     return null;
             // }
-
             assetBundle = await AssetBundleHelper.UnityLoadBundleAsync(p);
-
             if (assetBundle == null)
             {
                 // 获取资源的时候会抛异常,这个地方不直接抛异常,因为有些地方需要Load之后判断是否Load成功
                 Log.Warning($"assets bundle not found: {assetBundleName}");
                 return null;
             }
-
             abInfo = this.AddChild<ABInfo, string, AssetBundle>(assetBundleName, assetBundle);
             this.bundles[assetBundleName] = abInfo;
             return abInfo;

+ 1 - 0
Unity/ProjectSettings/GraphicsSettings.asset

@@ -38,6 +38,7 @@ GraphicsSettings:
   - {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0}
   - {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0}
   - {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0}
+  - {fileID: 16002, guid: 0000000000000000f000000000000000, type: 0}
   m_PreloadedShaders: []
   m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
     type: 0}