InvokeOnHotPatch
Run custom code after Hot Patch successfully applies one or more patches. Use the [InvokeOnHotPatch] attribute from the DivinityCodes.HotPatch runtime assembly.
Basic example
using System.Collections.Generic;
using DivinityCodes.HotPatch;
using UnityEngine;
public class GameBootstrap : MonoBehaviour
{
[InvokeOnHotPatch]
static void OnHotPatch(IReadOnlyList<HotPatchMethodPatch> patches)
{
foreach (var patch in patches)
Debug.Log($"Patched {patch.TypeFullName}.{patch.MethodName}");
}
}
Static vs instance
| Type |
When it runs |
| Static method |
Once per apply cycle, after all patches in that frame are flushed. |
| Instance method |
On every live MonoBehaviour of that type in the scene. |
Parameters
| Signature |
Valid? |
void OnHotPatch() |
Yes |
void OnHotPatch(IReadOnlyList<HotPatchMethodPatch> patches) |
Yes |
void OnHotPatch(HotPatchMethodPatch[] patches) |
Yes |
void OnHotPatch(List<HotPatchMethodPatch> patches) |
Yes |
The patch list parameter is optional. Patches applied in the same frame are delivered together in one batch.
HotPatchMethodPatch properties
| Property |
Description |
AssemblyName |
Assembly containing the patched type |
TypeFullName |
Full type name |
MethodName |
Patched method name |
MethodSignature |
Method signature string |
PatchedMethod |
MethodInfo of the patched method |
Rules
- Method must return
void
- Attribute is not inherited; one per method
- Only successful patches trigger callbacks
- Failed or skipped patches do not invoke handlers
- Method deletions and renames do not invoke handlers (rename = delete + add)
- Enable or disable in Options > Invoke
[InvokeOnHotPatch] methods