RoundManagerObjectReferenceFix

v1.0.0·Updated 2026-05-02

A mod for Lethal Company that prevents crashes caused by unresolved prefab references in custom moon mods.

About this mod Author’s original text

RoundManagerObjectReferenceFix

ℹ️ Only the host is required to install this mod. Should be fine for multiplayer and could potentially prevent crashes on other custom moons too.

A mod for Lethal Company that prevents crashes caused by unresolved prefab references in custom moon mods.

What it does

ℹ️ I created this mod for my own moon as I assigned blank references to the corresponding fields (to keep the mod size small), but the game could not resolve them and crash.

This mod runs during the spawn process of the RoundManager and tries to detect scrap, outside objects, and map hazards that do not have a prefab ( prefab = null).

It does the following when a prefab = null:

  • Scrap items:
  • If an item has a null prefab, it is replaced with a random valid item from the moon's item spawn list
  • Outside objects:
  • If an outside object has a null prefab, it is removed from the spawn pool to prevent a crash
  • Map objects:
  • If an Indoor hazard has a null prefab, it is removed from the spawn pool to prevent a crash

Logging is included so you can identify which objects are not resolving correctly and fix them in your moon configuration.

Example errors

On spawn outside hazards:

[Error: Unity Log] ArgumentException: The Object you want to instantiate is null.

Stack trace:

UnityEngine.Object.Instantiate (UnityEngine.Object original, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation, UnityEngine.Transform parent) (at:IL_0048)

UnityEngine.Object.Instantiate[T] (T original, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation, UnityEngine.Transform parent) (at:IL_0001)

RoundManager.SpawnOutsideHazards () (at:IL_049F)

DMD<>?434046712.Trampoline?-426100634 (RoundManager ) (at:IL_0025)

Dawn.MapObjectRegistrationHandler.SpawnOutsideMapObjects (On.RoundManager+orig_SpawnOutsideHazards orig, RoundManager self) (at./src/API/MapObjects.MapObjectRegistrationHandler.cs:275)

DMD<>?1224120700.Hook?1737978544 (RoundManager ) (at:IL_000F)

RoundManager.FinishGeneratingLevel () (at:IL_0040)

RoundManager.Generator_OnGenerationStatusChanged (DunGen.DungeonGenerator generator, DunGen.GenerationStatus status) (at:IL_000C)

DunGen.DungeonGenerator.ChangeStatus (DunGen.GenerationStatus status) (at:IL_0036)

DunGen.DungeonGenerator+d__131.MoveNext () (at:IL_049E)

UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at:IL_0026)

On spawning scrap

[Error: Unity Log] ArgumentException: The Object you want to instantiate is null.

Stack trace:

UnityEngine.Object.Instantiate (UnityEngine.Object original, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation) (at:IL_0049)

UnityEngine.Object.Instantiate (UnityEngine.Object original, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation, UnityEngine.Transform parent) (at:IL_000C)

UnityEngine.Object.Instantiate[T] (T original, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation, UnityEngine.Transform parent) (at:IL_0001)

RoundManager.SpawnScrapInLevel () (at:IL_0540)

DMD<>?2052090776.Trampoline?1603470438 (RoundManager ) (at:IL_0025)

Dawn.ItemRegistrationHandler.UpdateItemWeights (On.RoundManager+orig_SpawnScrapInLevel orig, RoundManager self) (at./src/API/Items.ItemRegistrationHandler.cs:107)

DMD<>?1148133988.Hook?1662684564 (RoundManager ) (at:IL_000F)

RoundManager.GeneratedFloorPostProcessing () (at:IL_0009)

RoundManager+d__167.MoveNext () (at:IL_05C5)

UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at:IL_0026)

Example of the fix

Outside "hazards" / objects:

[Info:RoundManagerObjectReferenceFix] Checking: SpawnOutsideHazards

[Info:RoundManagerObjectReferenceFix] Outside object 'SnowmanShort' | Prefab: Snowman OK

[Info:RoundManagerObjectReferenceFix] Outside object 'SnowmanTall' | Prefab: SnowmanTall OK

[Warning:RoundManagerObjectReferenceFix] Outside object 'TreeLeafless2Snowy' has null prefab, resolving

Install & use Install: BepInEx plugin

  1. The archive from playbuff is the mod itself — usually a BepInEx plugin (a .dll or a plugin folder once unzipped).
  2. Recommended: use a community mod manager (such as r2modman) — pick this game, import the mod, and the manager sets up BepInEx and its dependencies for you.
  3. Manual route: install the BepInEx loader in the game folder, then drop the unzipped .dll or plugin folder into BepInEx/plugins/.
  4. Launch the game — the BepInEx console logs every plugin it loads; seeing this mod in the log means it is installed.

Mods with listed dependencies need those installed too, or they will not load. Options are usually changed in-game or in the plugin's config file.

Dependencies

Install these first, or the mod will not work:

BepInEx-BepInExPack

File & checksum

Filename
RoundManagerObjectReferenceFix-1.0.0.zip
File size
92.1 KiB