123456789101112131415161718192021222324252627282930313233343536373839 |
- #if UNITY_EDITOR
- using UnityEditor;
- //using ILRuntime.Generated.CrossBinding;
- using System.Collections.Generic;
- [System.Reflection.Obfuscation(Exclude = true)]
- public class ILRuntimeCLRBinding
- {
- [MenuItem("ILRuntime/通过自动分析热更DLL生成CLR绑定")]
- static void GenerateCLRBindingByAnalysis()
- {
- //用新的分析热更dll调用引用来生成绑定代码
- ILRuntime.Runtime.Enviorment.AppDomain domain = new ILRuntime.Runtime.Enviorment.AppDomain();
- using (System.IO.FileStream fs = new System.IO.FileStream("Assets/Res/Code/Game.HotUpdate.dll.bytes", System.IO.FileMode.Open, System.IO.FileAccess.Read))
- {
- domain.LoadAssembly(fs);
- //Crossbind Adapter is needed to generate the correct binding code
- InitILRuntime(domain);
- ILRuntime.Runtime.CLRBinding.BindingCodeGenerator.GenerateBindingCode(domain, "Assets/Game/Launcher/ILRuntime/Generated");
- }
- AssetDatabase.Refresh();
- }
- static void InitILRuntime(ILRuntime.Runtime.Enviorment.AppDomain appdomain)
- {
- //这里需要注册所有热更DLL中用到的跨域继承Adapter,否则无法正确抓取引用
- //appdomain.RegisterCrossBindingAdaptor(new MonoBehaviourAdapter());
- //appdomain.RegisterCrossBindingAdaptor(new CoroutineAdapter());
- //appdomain.RegisterCrossBindingAdaptor(new GComponentAdapter());
- //appdomain.RegisterCrossBindingAdaptor(new IEnumerator());
- //appdomain.RegisterCrossBindingAdaptor(new ScriptableObjectAdapter());
- //appdomain.RegisterCrossBindingAdaptor(new WindowAdapter());
- //appdomain.RegisterValueTypeBinder(typeof(Vector3), new Vector3Binder());
- }
- }
- #endif
|