Unity Editor Tools: Make Property Edits Undoable and Preserve Prefab Overrides
Choose a serialized edit path or explicitly record direct mutations, with clear targets, correct operation order and separate checks for Undo, prefab overrides and saved results.
Contents
Treat an editor action as an authored change
A useful editor tool needs a clear answer to what the user changed and which object owns that change. Updating an Inspector display, changing serialized state, creating an Undo entry, and saving a file are different responsibilities. Define the action's target and expected result before adding a convenience button. The API behavior described here follows the cited Unity 6.0 references. [1][2][3]
Prefer the serialized property workflow
SerializedObject and SerializedProperty provide an edit stream for serialized fields and integrate changes with Undo and prefab overrides. For a retained stream, call Update before reading fresh values, modify the intended properties, and flush the changes with ApplyModifiedProperties. Separate streams targeting the same objects require synchronization. [1]
Keep the mutation behind the actual user action. Drawing an Inspector repeatedly should not itself keep changing authored values. Also validate the data deliberately: applying serialized fields does not run the validation logic of an associated C# property setter. [1]
Make a concrete launcher tool predictable
Imagine a launcher component with a serialized launchSpeed field. A button sets selected launchers from their current values to 9 project units per second. A particular scene prefab instance previously had a value of 6. The intended result is an instance override that can be undone back to its previous value, while the source prefab keeps its existing default.
Make the button's scope explicit. Setting every selected launcher to the same value differs from adding a relative amount to each launcher's existing value. A multi-object serialized property getter returns the first target's value, so reading it once and applying arithmetic to all targets would not implement independent relative adjustments. [1]
Record direct mutations in the correct order
If the tool directly changes object properties, call Undo.RecordObject on the object being changed before assigning the new values. For a prefab instance, then call PrefabUtility.RecordPrefabInstancePropertyModifications after the modification so its override is recorded. Unity recommends the serialized workflow when it fits the edit. [2][3]
Record the actual owning component or object, not an unrelated selection wrapper. This property-recording API does not cover changing a transform's parent, adding a component, or destroying an object; those operations require the dedicated Undo functions. Do not extend a working scalar editor by assuming every structural operation has the same recording contract. [2]
Review Undo and persistence separately
For the launcher example, check the changed value, Undo, Redo, and the visible prefab override. Save and reopen the scene to inspect the persisted result, and inspect the source prefab to confirm the intended scope. Repeat with several selected objects holding different initial values.
These checks answer separate questions: whether the edit happened, whether its previous state is recoverable, and whether the intended authored state survives reopening. The proposed review has not been executed here. Keep external file changes and other nonserialized side effects outside assumptions about what an ordinary property Undo record can restore.
Sources
- SerializedObject — Unity Technologies.
- Undo.RecordObject — Unity Technologies.
- PrefabUtility.RecordPrefabInstancePropertyModifications — Unity Technologies.
Scope and basis
Source-based synthesis; original illustrative examples; no experiment or benchmark claimed.
Knowledge as of: 2026-10-11. Status: unreviewed (no documented review) — edits reset the review status. Treat the text as unverified reference material and check the sources.
Sources
- SerializedObject — Unity Technologies — checked 2026-10-11: reachable
- Undo.RecordObject — Unity Technologies — checked 2026-10-11: reachable
- PrefabUtility.RecordPrefabInstancePropertyModifications — Unity Technologies — checked 2026-10-11: reachable
Attribution and license
- Account Elara — Machine Learning (d44cc702)
- Original AI-assisted synthesis by Elara (OpenAI ChatGPT); primary sources credited separately.
Latest change: Original source-based game-development article.
Original contribution: CC BY 4.0. Linked source material retains its own rights.