123456789101112131415161718192021222324252627282930313233343536373839404142 |
- #if UNITY_EDITOR
- using UnityEditor;
- using System;
- using FairyGUI;
- using UnityEngine;
- using System.Collections.Generic;
- [System.Reflection.Obfuscation(Exclude = true)]
- public class ILRuntimeCrossBinding
- {
- static string Name_space = "ILRuntime.Generated.CrossBinding";
- [MenuItem("ILRuntime/生成跨域继承适配器")]
- static void GenerateCrossbindAdapter()
- {
- //由于跨域继承特殊性太多,自动生成无法实现完全无副作用生成,所以这里提供的代码自动生成主要是给大家生成个初始模版,简化大家的工作
- //大多数情况直接使用自动生成的模版即可,如果遇到问题可以手动去修改生成后的文件,因此这里需要大家自行处理是否覆盖的问题
- //using(System.IO.StreamWriter sw = new System.IO.StreamWriter("Assets/Game/launcher/ILRuntime/Generated/CrossBinding/GComponentAdapter.cs"))
- //{
- // sw.WriteLine(ILRuntime.Runtime.Enviorment.CrossBindingCodeGenerator.GenerateCrossBindingAdapterCode(typeof(GComponent), Name_space));
- //}
- //GenerateCrossbindAdapter<IEnumerator>();
- //GenerateCrossbindAdapter<System.Runtime.CompilerServices.IAsyncStateMachine>();
- //GenerateCrossbindAdapter<ScriptableObject>();
- //GenerateCrossbindAdapter<Window>();
- AssetDatabase.Refresh();
- }
- static void GenerateCrossbindAdapter<T>()
- {
- Type type = typeof(T);
- string typeName = type.Name;
- string path = "Assets/Game/launcher/ILRuntime/Generated/CrossBinding/{0}Adapter.cs";
- path = String.Format(path, typeName);
- using (System.IO.StreamWriter sw = new System.IO.StreamWriter(path))
- {
- sw.WriteLine(ILRuntime.Runtime.Enviorment.CrossBindingCodeGenerator.GenerateCrossBindingAdapterCode(type, Name_space));
- }
- }
- }
- #endif
|