LinkGeneratorCommand.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. using Analyzer = HybridCLR.Editor.Link.Analyzer;
  11. public static class LinkGeneratorCommand
  12. {
  13. [MenuItem("HybridCLR/Generate/LinkXml", priority = 100)]
  14. public static void GenerateLinkXml()
  15. {
  16. BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
  17. CompileDllCommand.CompileDll(target);
  18. GenerateLinkXml(target);
  19. }
  20. public static void GenerateLinkXml(BuildTarget target)
  21. {
  22. var ls = SettingsUtil.HybridCLRSettings;
  23. List<string> hotfixAssemblies = SettingsUtil.HotUpdateAssemblyNamesExcludePreserved;
  24. var analyzer = new Analyzer(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotfixAssemblies));
  25. var refTypes = analyzer.CollectRefs(hotfixAssemblies);
  26. Debug.Log($"[LinkGeneratorCommand] hotfix assembly count:{hotfixAssemblies.Count}, ref type count:{refTypes.Count} output:{Application.dataPath}/{ls.outputLinkFile}");
  27. var linkXmlWriter = new LinkXmlWriter();
  28. linkXmlWriter.Write($"{Application.dataPath}/{ls.outputLinkFile}", refTypes);
  29. AssetDatabase.Refresh();
  30. }
  31. }
  32. }