LinkGeneratorCommand.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using HybridCLR.Editor.Link;
  2. using HybridCLR.Editor.Meta;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Reflection;
  6. using UnityEditor;
  7. using UnityEngine;
  8. namespace HybridCLR.Editor.Commands
  9. {
  10. public static class LinkGeneratorCommand
  11. {
  12. [MenuItem("HybridCLR/Generate/LinkXml", priority = 100)]
  13. public static void GenerateLinkXml()
  14. {
  15. BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
  16. CompileDllCommand.CompileDll(target);
  17. GenerateLinkXml(target);
  18. }
  19. public static void GenerateLinkXml(BuildTarget target)
  20. {
  21. var ls = SettingsUtil.HybridCLRSettings;
  22. List<string> hotfixAssemblies = SettingsUtil.HotUpdateAssemblyNames;
  23. var analyzer = new Analyzer(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotfixAssemblies), HybridCLRSettings.Instance.collectAssetReferenceTypes);
  24. var refTypes = analyzer.CollectRefs(hotfixAssemblies);
  25. Debug.Log($"[LinkGeneratorCommand] hotfix assembly count:{hotfixAssemblies.Count}, ref type count:{refTypes.Count} output:{Application.dataPath}/{ls.outputLinkFile}");
  26. var linkXmlWriter = new LinkXmlWriter();
  27. linkXmlWriter.Write($"{Application.dataPath}/{ls.outputLinkFile}", refTypes);
  28. AssetDatabase.Refresh();
  29. }
  30. }
  31. }