diff --git a/Editor/Commands/Il2CppDefGeneratorCommand.cs b/Editor/Commands/Il2CppDefGeneratorCommand.cs index 6a9e175..3030686 100644 --- a/Editor/Commands/Il2CppDefGeneratorCommand.cs +++ b/Editor/Commands/Il2CppDefGeneratorCommand.cs @@ -18,7 +18,9 @@ namespace HybridCLR.Editor.Commands var options = new Il2CppDef.Il2CppDefGenerator.Options() { UnityVersion = Application.unityVersion, + HotUpdateAssemblies = SettingsUtil.HotUpdateAssemblyNames, OutputFile = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp/il2cpp-config.h", + OutputFile2 = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp/hybridclr/Il2CppCompatibleDef.cpp", }; var g = new Il2CppDef.Il2CppDefGenerator(options); diff --git a/Editor/Il2CppDef/Il2CppDefGenerator.cs b/Editor/Il2CppDef/Il2CppDefGenerator.cs index ae1a8c0..8728c65 100644 --- a/Editor/Il2CppDef/Il2CppDefGenerator.cs +++ b/Editor/Il2CppDef/Il2CppDefGenerator.cs @@ -15,8 +15,12 @@ namespace HybridCLR.Editor.Il2CppDef { public class Options { + public List HotUpdateAssemblies { get; set; } + public string OutputFile { get; set; } + public string OutputFile2 { get; set; } + public string UnityVersion { get; set; } } @@ -30,6 +34,12 @@ namespace HybridCLR.Editor.Il2CppDef private static readonly Regex s_unityVersionPat = new Regex(@"(\d+)\.(\d+)\.(\d+)"); public void Generate() + { + GenerateIl2CppConfig(); + GeneratePlaceHolderAssemblies(); + } + + private void GenerateIl2CppConfig() { var frr = new FileRegionReplace(File.ReadAllText(_options.OutputFile)); @@ -55,5 +65,22 @@ namespace HybridCLR.Editor.Il2CppDef frr.Commit(_options.OutputFile); Debug.Log($"[HybridCLR.Editor.Il2CppDef.Generator] output:{_options.OutputFile}"); } + + private void GeneratePlaceHolderAssemblies() + { + var frr = new FileRegionReplace(File.ReadAllText(_options.OutputFile2)); + + List lines = new List(); + + foreach (var ass in _options.HotUpdateAssemblies) + { + lines.Add($"\t\t\"{ass}\","); + } + + frr.Replace("PLACE_HOLDER", string.Join("\n", lines)); + + frr.Commit(_options.OutputFile2); + Debug.Log($"[HybridCLR.Editor.Il2CppDef.Generator] output:{_options.OutputFile2}"); + } } }