ILRuntimeCrossBinding.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #if UNITY_EDITOR
  2. using UnityEditor;
  3. using System;
  4. using FairyGUI;
  5. using UnityEngine;
  6. using System.Collections.Generic;
  7. [System.Reflection.Obfuscation(Exclude = true)]
  8. public class ILRuntimeCrossBinding
  9. {
  10. static string Name_space = "ILRuntime.Generated.CrossBinding";
  11. [MenuItem("ILRuntime/生成跨域继承适配器")]
  12. static void GenerateCrossbindAdapter()
  13. {
  14. //由于跨域继承特殊性太多,自动生成无法实现完全无副作用生成,所以这里提供的代码自动生成主要是给大家生成个初始模版,简化大家的工作
  15. //大多数情况直接使用自动生成的模版即可,如果遇到问题可以手动去修改生成后的文件,因此这里需要大家自行处理是否覆盖的问题
  16. //using(System.IO.StreamWriter sw = new System.IO.StreamWriter("Assets/Game/launcher/ILRuntime/Generated/CrossBinding/GComponentAdapter.cs"))
  17. //{
  18. // sw.WriteLine(ILRuntime.Runtime.Enviorment.CrossBindingCodeGenerator.GenerateCrossBindingAdapterCode(typeof(GComponent), Name_space));
  19. //}
  20. //GenerateCrossbindAdapter<IEnumerator>();
  21. //GenerateCrossbindAdapter<System.Runtime.CompilerServices.IAsyncStateMachine>();
  22. //GenerateCrossbindAdapter<ScriptableObject>();
  23. //GenerateCrossbindAdapter<Window>();
  24. AssetDatabase.Refresh();
  25. }
  26. static void GenerateCrossbindAdapter<T>()
  27. {
  28. Type type = typeof(T);
  29. string typeName = type.Name;
  30. string path = "Assets/Game/launcher/ILRuntime/Generated/CrossBinding/{0}Adapter.cs";
  31. path = String.Format(path, typeName);
  32. using (System.IO.StreamWriter sw = new System.IO.StreamWriter(path))
  33. {
  34. sw.WriteLine(ILRuntime.Runtime.Enviorment.CrossBindingCodeGenerator.GenerateCrossBindingAdapterCode(type, Name_space));
  35. }
  36. }
  37. }
  38. #endif