Compatibility, IL2CPP Patterns, and Troubleshooting
Intended scope
Section titled “Intended scope”- Coroutines —
MelonCoroutines.Start(enumerator)(notStartCoroutine); the AnomalyCoroutineshelper. - Cross-scene state —
UnityEngine.Object.DontDestroyOnLoad(go)on survivors. - Custom
MonoBehaviours —[RegisterTypeInIl2Cpp]plus the two-constructor pattern ((IntPtr)+ parameterless). - Managed collections on a registered
MonoBehaviour—[HideFromIl2Cpp]on any method that touchesDictionary/List/etc. - IL2CPP-event delegates —
DelegateSupport.ConvertDelegate<T>when binding managed handlers to IL2CPP events (seeClientRuntime.Initialize/ShotEventManager.OnShot). - Common footguns — missing
MelonAdditionalDependencies("Anomaly"), subscribing to one-shot events too late (no replay), touchingLocalPlayerbeforeClientEvents.Ready. - Reading stack traces that cross managed + IL2CPP boundaries.
Sources
Section titled “Sources”E:\Projects\AnomalyLabs\Anomaly\Anomaly.Client.Api\MODDING.md— “IL2CPP gotchas” and “Lifecycle”.Anomaly.Client\Runtime\ClientRuntime.cs— reference pattern for IL2CPP delegate conversion.