Skip to main content
Version: v3

HotfixHelper

Important Attention Reminder

Coding Style wiki


HotfixHelper is the Hotfixer editor helper, used to compile and collect the AOT / Hotfix DLLs into the HotfixCollector directory and to export the hotfix DLL config file (HotfixManifest.dat) read by the auto-config mode of Hotfixers.CheckHotfix at runtime.

NamespaceOxGFrame.Hotfixer.Editor
Typepublic static class
SourceHotfixHelper.cs
using OxGFrame.Hotfixer.Editor;

Attention This class is for the Unity Editor environment only.

Method Overview

MethodDescription
CompileAndCopyToHotfixCollectorCompiles the hotfix DLLs and collects the AOT / Hotfix DLLs into HotfixCollector in one click.
CopyAOTDllsAndHotfixDllsCopies both the AOT and Hotfix DLLs into the HotfixCollector directory in one click.
CopyAOTAssembliesToDestinationCopies the AOT DLLs (post-IL2CPP-strip) to the destination directory.
CopyHotfixAssembliesToDestinationCopies the Hotfix DLLs to the destination directory.
ExportHotfixDllConfigExports the hotfix DLL config file (HotfixManifest.dat) to StreamingAssets.
ToRelativeAssetPathConverts an absolute path into a relative path starting with Assets/.

CompileAndCopyToHotfixCollector

public static void CompileAndCopyToHotfixCollector()

Description

Compiles the hotfix DLLs for the current build target (activeBuildTarget) via HybridCLR's CompileDllCommand.CompileDll, then runs CopyAOTDllsAndHotfixDlls to collect the AOT and Hotfix DLLs into the HotfixCollector directory.

Reminder Corresponds to the editor menu HybridCLR → OxGFrame With HybridCLR → Compile And Copy To HotfixCollector. After collecting, pack the files with the YooAsset Collector — see the Collection Example.


CopyAOTDllsAndHotfixDlls

public static void CopyAOTDllsAndHotfixDlls()

Description

Runs CopyAOTAssembliesToDestination and CopyHotfixAssembliesToDestination in sequence (both with their default output directories), collecting all related files into the Assets/HotfixCollector directory.


CopyAOTAssembliesToDestination

public static void CopyAOTAssembliesToDestination(string dstDir = null)

Parameters

ParameterTypeDescription
dstDirstringCustom output directory.
Default: null (outputs to Assets/HotfixCollector/AOTDlls)

Description

Copies the post-IL2CPP-strip AOT DLLs for the current build target (listed by HybridCLR's SettingsUtil.AOTAssemblyNames) to the destination directory, writing them as <assembly name>.dll.bytes so they can be collected and loaded as assets.

Attention The destination directory is deleted and recreated before copying — do not keep other files in it.

Important The stripped AOT DLLs are only generated after HybridCLR → Generate All (or a player build). If the Console reports missing files, run Generate All first.


CopyHotfixAssembliesToDestination

public static void CopyHotfixAssembliesToDestination(string dstDir = null)

Parameters

ParameterTypeDescription
dstDirstringCustom output directory.
Default: null (outputs to Assets/HotfixCollector/HotfixDlls)

Description

Copies the hotfix DLLs compiled by HybridCLR for the current build target (listed by SettingsUtil.HotUpdateAssemblyFilesExcludePreserved) to the destination directory, automatically appending the .bytes extension (written as <assembly name>.dll.bytes).

Attention The destination directory is deleted and recreated before copying — do not keep other files in it.


ExportHotfixDllConfig

public static void ExportHotfixDllConfig(List<string> aotDlls, List<string> hotfixDlls, bool cipher)

Parameters

ParameterTypeDescription
aotDllsList<string>List of AOT assemblies that need metadata supplementation (names include the .dll extension).
hotfixDllsList<string>List of hotfix assemblies (names include the .dll extension).
cipherboolWhether to encrypt. true exports the encrypted BYTES format; false exports plaintext JSON.

Description

Writes the AOT and hotfix assembly lists into the hotfix DLL config file and exports it to the built-in StreamingAssets (the file name follows HotfixSettings, HotfixManifest.dat by default), to be read by the auto-config mode of Hotfixers.CheckHotfix at runtime.

The plaintext JSON format looks like this:

{
"aotDlls": [
"mscorlib.dll",
"UniTask.dll"
],
"hotfixDlls": [
"HotfixerDemo.Hotfix.Runtime.dll"
]
}

The encrypted BYTES format writes a cipher marker into the file header and XOR-encrypts the content with the cipher key from HotfixSettings; at runtime the format is auto-detected by the file header.

Reminder
  • You can also generate the file with the editor window tool via the menu OxGFrame → Hotfixer → Hotfix Config Generator (HotfixManifest.dat) (with preset plan management support).
  • An exported config file can be converted between the plaintext and encrypted formats by selecting it in the Project window and using the menu Assets → OxGFrame → Hotfixer → Convert HotfixManifest.dat (BYTES [Cipher] <-> JSON [Plaintext]) (only valid for a matching config file located inside StreamingAssets).

Example

using OxGFrame.Hotfixer.Editor;
using System.Collections.Generic;

HotfixHelper.ExportHotfixDllConfig(
// AOT assemblies that need metadata supplementation
new List<string> { "mscorlib.dll", "UniTask.dll" },
// Hotfix assemblies
new List<string> { "HotfixerDemo.Hotfix.Runtime.dll" },
// Encrypted output
true
);

ToRelativeAssetPath

public static string ToRelativeAssetPath(string s)

Parameters

ParameterTypeDescription
sstringFull file path (must contain the Assets/ segment).

Returns

string — the project-relative path starting with Assets/.

Description

Converts an absolute path into a path relative to the project's Assets/ directory (extracts the substring starting at Assets/).