Skip to content

Debug a Unity Game That Works in Play Mode but Fails in a Build

Compare Unity Editor and player behavior using matching routes, real player logs, build configuration, and one controlled hypothesis at a time.

Published

4 min read

A successful Play mode session proves that one Editor configuration worked. A player build can use a different entry scene, compiled code path, content set, storage location, or timing. The investigation needs to identify the meaningful difference rather than treating every build-only failure as a stripping problem.

Imagine a level-selection screen that opens correctly in the Editor but shows no levels in the exported game. Follow the earliest missing piece: configuration, loaded data, parsed records, or the UI that displays them. Keep the working and failing artifacts available throughout the comparison.

/01

Make the Editor take the same route

Start from the application’s intended entry scene and perform the same actions in both environments. Opening the level-selection scene directly may bypass the bootstrap that fails in the build. Record the source revision, platform, build configuration, and initial data state so the comparison has a clear subject.

Check whether the Editor already contains objects, selections, or cached data that the player does not have. Use a fresh disposable profile where appropriate. In the fictional example, establish whether the Editor menu still works after starting from the normal boot sequence with no previously loaded level catalogue.

/02

Read the player’s evidence before changing settings

Collect logs from the actual player environment. Unity documents platform-specific log locations and browser Console output for Web builds. Preserve the earliest relevant exception or failure together with the action that preceded it. Later UI errors may be consequences of the original data load failing.

Add small diagnostic checkpoints only where the evidence is missing: application initialized, catalogue requested, data received, records accepted, menu populated. Include success and failure outcomes without logging sensitive content. These checkpoints should distinguish stages, not fill the log with every frame or suppress the exception that explains the failure.

/03

Compare included code, configuration, and content

Inspect platform-dependent compilation and assembly constraints around the failing path. Unity’s conditional-compilation documentation explains how code can be included or excluded for different targets. Confirm that production behavior is not accidentally inside an Editor-only branch and that a development fallback is not masking missing runtime setup.

Inspect the candidate’s actual content-loading contract. Verify the requested key or path, the corresponding build content, and the selected environment configuration. If the catalogue is present but empty after parsing, investigate that stage separately. Do not replace the failed load with sample levels simply to make the menu appear functional.

/04

Test one explanation at a time

Choose a change that can discriminate between the remaining causes. A diagnostic build with additional error detail may reveal a missing resource; a controlled fixture may distinguish loading from parsing. Keep each experiment tied to a prediction and revert experiments that do not belong in the final repair.

Consider stripping only when the evidence points toward code reached in a way the build analysis cannot establish. Unity documents managed stripping and explicit preservation mechanisms, but broad preservation can hide the actual dependency. Likewise, adding a delay may change a race without defining correct initialization. Repair the confirmed dependency or state transition rather than retaining a lucky timing adjustment.

/05

Verify the repair in the release configuration

Run the original route in a newly exported candidate using the intended configuration. Confirm that the level list comes from the correct data, that selection loads the intended level, and that missing data still produces a truthful error. A diagnostic configuration passing is useful but does not establish that the final release behaves identically.

Repeat the Editor route to detect a regression introduced by the platform fix. Record the cause, the exact build setting or code change, and the evidence from both environments. Keep unsupported platforms marked untested. The result should explain why the environments differed and why the narrow correction resolves that difference.

Keep this in mind

Key takeaways

  • Compare the same startup route and data state before attributing a failure to the build pipeline.
  • Use the earliest player error to distinguish code inclusion, content loading, parsing, and presentation.
  • Verify the final release configuration and preserve truthful failure behavior after the repair.

Sources & further reading

Consult the source documentation for the version and platform you are working with.