Programming & Scripting Errors Mar 12, 2026

Unity Scripts Not Executing - MonoBehaviour Issues (How to Fix)

Unity scripts not running or MonoBehaviour not executing? Fix Start/Update not being called with this step-by-step troubleshooting guide and verification steps.

By GamineAI Team

Unity Scripts Not Executing - MonoBehaviour Issues (How to Fix)

Problem Statement

Your Unity C# scripts are attached to GameObjects but nothing happens when you enter Play mode: Start(), Update(), or other MonoBehaviour methods never run. Sometimes only some scripts run while others stay silent, or behavior is inconsistent between sessions. This blocks gameplay logic, input, movement, and any code that depends on the Unity lifecycle.

Common symptoms:

  • Start() or Update() never gets called
  • Breakpoints in your script are never hit when running the game
  • Script is attached to a GameObject but has no effect in Play mode
  • Some scripts run and others on the same scene do not
  • Script worked before and stopped after a change (reimport, upgrade, or refactor)

Root Cause Explanation

MonoBehaviour scripts can fail to execute for several reasons:

  • Script compilation errors – If any script in the project has a compile error, Unity may not load your script or may strip it from the build.
  • GameObject or component disabled – The GameObject or the script component might be inactive (SetActive(false) or the checkbox cleared in the Inspector).
  • Script not derived from MonoBehaviour – The class must inherit from MonoBehaviour and live in a file that matches the class name.
  • Missing or broken script reference – The serialized reference to the script is broken (e.g. script moved, renamed, or deleted and recreated).
  • Execution order – Another script might disable the GameObject or change state before your script runs.
  • Scene not loaded or object destroyed – The object might be in an additive scene that is not loaded, or destroyed before your code runs.
  • Editor vs build – Code might be wrapped in #if UNITY_EDITOR or conditional compilation so it only runs in the editor or only in builds.

This guide walks you through checks and fixes so your MonoBehaviour code runs reliably.


Quick Fixes (Try These First)

1. Confirm the GameObject and Script Are Active

Unity only runs scripts on active GameObjects with the component enabled.

Steps:

  1. Select the GameObject that has your script in the Hierarchy.
  2. In the Inspector, ensure the checkbox at the top left of the GameObject is checked (active).
  3. Find your script component and ensure its checkbox (next to the script name) is checked.
  4. Enter Play mode and test again.

Verification: Toggle the component off and on while in Play mode; behavior should turn off and on. If it does, the script is running and the issue was activation.

If this doesn't work: Continue to the next step.

2. Fix All Script Compilation Errors

One compile error in the project can prevent scripts from loading or executing correctly.

Steps:

  1. Open Window → General → Console (or Ctrl+Shift+C).
  2. Resolve every red error (not just warnings). Fix or temporarily comment out the offending code.
  3. Wait until the bottom-right of the Unity editor shows "Compilation successful" (no spinning icon).
  4. Enter Play mode again.

Verification: With zero compilation errors, all valid MonoBehaviours should be considered by Unity. Add a simple Debug.Log("Script running"); in Start() and confirm it appears in the Console when you enter Play mode.

Common causes: Missing using directives, typos in type names, duplicate class names, or assemblies not referenced. See the Unity C# Compilation Errors guide for more detail.

3. Confirm the Class Is a MonoBehaviour

Unity only invokes lifecycle methods on components that derive from MonoBehaviour.

Steps:

  1. Open your script in your IDE.
  2. Ensure the class inherits from MonoBehaviour:
    • Correct: public class MyPlayer : MonoBehaviour
    • Incorrect: public class MyPlayer or public class MyPlayer : MonoBehaviourBase
  3. Ensure the file name matches the class name (e.g. MyPlayer.cs for class MyPlayer).
  4. Save and return to Unity; let it recompile.

Verification: After recompile, the component should still be attached. Enter Play mode and check that your Start() or Update() logic runs (e.g. via Debug.Log or a visible change in the Scene).

4. Check for a Broken Script Reference (Missing Script)

If the Inspector shows "Missing (Mono Script)" or an empty script slot, Unity cannot execute that component.

Steps:

  1. Select the GameObject and look at the script component in the Inspector.
  2. If it says Missing (Mono Script) or the script reference is empty:
    • Remove the broken component (three-dots menu → Remove Component).
    • Drag the correct script from the Project window onto the GameObject, or use Add Component and search for your script name.
  3. Save the scene (Ctrl+S).

Verification: The Inspector should show your script name and its serialized fields. Enter Play mode and confirm the script runs.

Prevention: Avoid renaming script files or moving them after they are in use without using refactoring tools. If you must rename, do it from the Unity Project window or your IDE with Unity closed, then fix any missing references.

5. Ensure the Object Is in the Loaded Scene

Scripts on GameObjects in scenes that are not loaded will not run.

Steps:

  1. Check File → Build Settings and ensure your scene is in "Scenes In Build" and enabled.
  2. If you use additive loading, ensure you call SceneManager.LoadScene("YourScene", LoadSceneMode.Additive) (or equivalent) before expecting the script to run.
  3. Confirm in the Hierarchy at runtime that the GameObject is present and active.

Verification: In Play mode, the GameObject appears in the Hierarchy and your script's Start() log or behavior runs.


Step-by-Step Solution (Systematic Check)

If quick fixes did not resolve it, go through this order.

Step 1: Add a Minimal Test in Start()

Isolate whether the problem is "this script" or "this GameObject/scene."

Action:

  1. Open your script and add at the top of Start():
    • Debug.Log("MyScript.Start called on " + gameObject.name);
  2. Enter Play mode and watch the Console.
  3. If the message appears: the script is running; the issue is likely in your logic (conditions, other components, or execution order).
  4. If the message does not appear: the script is not executing; continue with the steps below.

Step 2: Re-add the Script Component

Serialization can be corrupted so that the component exists but never runs.

Action:

  1. Note or copy the values of any serialized fields in the Inspector.
  2. Remove the script component from the GameObject.
  3. Use Add Component, search for your script, and add it again.
  4. Restore any field values you noted.
  5. Save the scene and enter Play mode.

Verification: Start()/Update() run and your Debug.Log appears.

Step 3: Check Execution Order (Optional)

If multiple scripts depend on each other, one might disable the GameObject or change state before your script runs.

Action:

  1. Go to Edit → Project Settings → Script Execution Order.
  2. Find your script in the list. Default is 0.
  3. If another script must run first, give it a lower (e.g. negative) value; give your script a higher value if it must run after others.
  4. Use this sparingly; prefer explicit initialization or messaging instead of relying on order.

Verification: Behavior is consistent when entering Play mode; no script is "too late" or "too early."

Step 4: Rule Out Editor-Only or Build-Only Code

Conditional compilation can make code run only in the editor or only in builds.

Action:

  1. Search your script for #if UNITY_EDITOR, #if !UNITY_EDITOR, or other #if blocks around Start()/Update().
  2. If your logic is inside an editor-only block, it will not run in builds; move shared logic outside the block or use a separate runtime script.
  3. Test both in the Editor and in a development build to see where it fails.

Verification: The same code path runs in the context where you expect it (Editor or build).


Alternative Fixes and Edge Cases

  • Domain Reload disabled: If Enter Play Mode Options has "Reload Domain" turned off, static state and sometimes script loading can be inconsistent. Re-enable domain reload for troubleshooting, or ensure your script does not rely on static state that persists between sessions.
  • Assembly Definition (asmdef) issues: If your script is in an assembly that does not reference Unity's assemblies correctly, or is not compiled before the default assemblies, it may not run as expected. Check Assembly Definition references and compile order. See Unity Build Fails with Error CS0246 for assembly-related fixes.
  • Script in a custom assembly that never runs: Ensure the assembly is referenced by the main game and that there are no circular dependencies or compile errors in that assembly.
  • Awake vs Start: Awake() runs before Start(). If you only put logic in Start() and another script disables the object in Awake(), your Start() might not run. Prefer Awake() for critical setup when order matters, or use Script Execution Order.

Prevention Tips

  • Keep zero compilation errors before entering Play mode; fix or exclude broken scripts so Unity can load all MonoBehaviours.
  • Avoid renaming or moving script files after they are in use; use refactor-rename in your IDE and then fix references in Unity if needed.
  • Use a single entry point (e.g. a GameManager) to initialize systems instead of depending on script execution order where possible.
  • Confirm in the Inspector that the script component is present and enabled, and that the GameObject is active, before debugging logic.
  • Use Debug.Log sparingly but strategically in Awake()/Start() when adding new scripts to confirm they run in the right scene and build.

Related Problems and Links

For official lifecycle and execution order details, see Unity's documentation: Execution order of event functions.


Bookmark this fix for quick reference the next time a script refuses to run. If you're still stuck, check our Unity Beginner Guide for project setup and script attachment basics. Share this article with your dev friends if it helped.