UnitySerializedShield
A Visual Studio extension that automatically adds [FormerlySerializedAs] when you rename serialized Unity fields — so you never lose Inspector, prefab, scene, or ScriptableObject values again.
The Problem
Unity stores serialized field data by field name. The moment you rename a [SerializeField] field without migration metadata, Unity silently drops the old value — and you lose:
- Inspector-tuned values
- Prefab overrides
- Scene references
- ScriptableObject configuration
The fix is straightforward — add [FormerlySerializedAs("oldName")] — but it's easy to forget, especially during a refactor sprint.
What UnitySerializedShield Does
When it detects a [SerializeField] field rename in your C# scripts, the extension automatically inserts the [FormerlySerializedAs] migration attribute above the renamed field, and adds using UnityEngine.Serialization; if it's not already present.
No manual steps. No forgotten migrations.
Features
- Watches C# files live inside Visual Studio
- Detects
[SerializeField] field renames automatically
- Inserts
[FormerlySerializedAs("oldName")] above the renamed field
- Adds
using UnityEngine.Serialization; when needed
- Avoids inserting duplicate migration attributes
- Skips ambiguous renames instead of guessing
Example
Before rename:
[SerializeField] private float maxDistance = 100f;
After renaming maxDistance → attackDistance:
using UnityEngine.Serialization;
[FormerlySerializedAs("maxDistance")]
[SerializeField] private float attackDistance = 100f;
Unity will now correctly reconnect the old serialized value to the new field name.
Requirements
| Requirement |
Details |
| Visual Studio |
2022 or newer |
| Unity |
Any version using [SerializeField] |
| Project type |
Unity C# scripts |
Supported editions: Community · Professional · Enterprise
Installation
Install directly from the Visual Studio Marketplace:
- Open Visual Studio
- Go to Extensions → Manage Extensions
- Search for UnitySerializedShield
- Click Download and restart Visual Studio
Notes
- This extension only modifies C# source files. It does not touch Unity scenes, prefabs, or asset files directly — Unity applies the migration itself at import time using the added attribute.
- Ambiguous renames (e.g. multiple fields with similar names) are skipped to avoid incorrect migrations.
Contributing
Issues and pull requests are welcome. If you run into a rename case that isn't handled correctly, please open an issue with a minimal repro.
License
MIT