HotPatchSettingsIntegration.cs 996 B

123456789101112131415161718192021222324252627
  1. using System;
  2. using HybridCLR.Settings;
  3. using UnityEditor;
  4. using UnityEditorInternal;
  5. namespace HotPatch.Editor
  6. {
  7. [InitializeOnLoad]
  8. public static class HotPatchSettingsIntegration
  9. {
  10. static HotPatchSettingsIntegration() => HotPatchAssemblySelection.ApplyHybridCLRSettings = Apply;
  11. public static void Apply(AssemblyDefinitionAsset assembly)
  12. {
  13. if (assembly != null) HotPatchAssemblySelection.Validate(assembly);
  14. var settings = HybridCLRSettings.instance;
  15. Undo.RecordObject(settings, "Select hot-patch assembly");
  16. settings.enable = true;
  17. settings.hotUpdateAssemblyDefinitions = assembly != null ? new[] { assembly } : Array.Empty<AssemblyDefinitionAsset>();
  18. settings.hotUpdateAssemblies = Array.Empty<string>();
  19. settings.preserveHotUpdateAssemblies = Array.Empty<string>();
  20. EditorUtility.SetDirty(settings);
  21. HybridCLRSettings.Save();
  22. }
  23. }
  24. }