WORKFLOW • PREFABS

Unity Prefab Changes Not Saving in Scene

Understand why modified variables or child objects revert to their original state when reloading scenes or restarting the editor.

How to Save Prefab Modifications Permanently

  1. Apply Overrides to Asset: Select the Prefab instance in your scene hierarchy, look at the top-right of the Inspector for the Overrides dropdown, and click Apply All.
  2. Edit in Prefab Stage: Double-click the Prefab in your Project window to enter isolated Prefab Editing mode. Any changes made here save directly to the root source asset automatically.

Understanding Unity Prefab Overrides and Asset Serialization

One of the most infuriating occurrences for indie developers is spending hours tweaking weapon fire rates, collider offsets, or script variables on a hierarchy GameObject, only to find all changes mysteriously discarded upon reloading the scene or restarting Unity. This issue arises from misunderstanding how Unity separates Prefab Asset files (on disk in the Project window) from Prefab Instances (in an open scene hierarchy).

Why Hierarchy Edits Revert Unexpectedly

  • Changes Made in Play Mode: If you modify inspector values while the Unity Play button is active, Unity will reset all GameObject parameters back to their pre-play state the moment Play Mode is stopped. Always exit Play Mode or copy the component before stopping to preserve numbers.
  • Unapplied Prefab Overrides: When you modify a prefab in the scene hierarchy, Unity highlights the modified fields with a vertical blue line. These changes exist purely as local instance overrides. If you delete the instance or re-instantiate from the project asset, those changes will vanish unless you click Overrides → Apply All.
  • Prefab Mode vs Scene Isolation: Double-clicking the prefab asset opens Prefab Isolation Mode. Edits made in Prefab Mode automatically write directly to disk on .prefab assets, permanently updating all instances across all scenes.

How to Guarantee Prefab Persistence

  1. Select the modified GameObject in the scene hierarchy.
  2. In the top right of the Inspector, click the Overrides dropdown button.
  3. Review the modified property list to ensure unintended changes are not included.
  4. Click Apply All to commit changes back to the source .prefab asset on disk.
  5. Press Ctrl + S (Cmd + S on Mac) to save both the scene and project asset database.
EditorPrefabSaver.cs (Editor Scripting)
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;

public static class EditorPrefabSaver
{
    // Menu shortcut to forcefully commit selected hierarchy prefab overrides to disk
    [MenuItem("Khawajja Tools/Apply Selected Prefab Overrides %#&s")]
    public static void ApplyOverrides()
    {
        GameObject selected = Selection.activeGameObject;
        if (selected != null && PrefabUtility.IsPartOfPrefabInstance(selected))
        {
            PrefabUtility.ApplyPrefabInstance(selected, InteractionMode.UserAction);
            AssetDatabase.SaveAssets();
            Debug.Log($"<color=green>[Prefab Saved]</color> Successfully applied overrides for '{selected.name}' to disk!");
        }
    }
}
#endif