Skip to main content

SerializeReference Tooling

References to renamed and deleted classes are found across the project and repaired in one go — before they turn into null in a build.

Quick start​

note

Binary assets and Git LFS files that were not fetched are skipped silently: keep Asset Serialization → Mode on Force Text (the default) and fetch LFS files before the check.

Project References: repair a group​

Project References and Asset References are tabs of one window. Scan Project reads the .prefab, .asset and .unity files under Assets/, apart from Excluded scan folders.

Project References with Fix all, Smart Fix → Pistol and Migrate all groupsProject References with Fix all, Smart Fix → Pistol and Migrate all groups

Group actions​

GroupHeader buttonRow under the header
Missing typeFix all ▼ — pick a class for every entrySmart Fix → Pistol — apply a class with the same or a similar name; the tooltip gives the reason
Renamed with [MovedFrom]Reassign all ▼ — pick a different class instead of the new nameMigrate all → Crossbow — write the new name, see Migrations

Every action asks for Rewrite. <None> in the class picker clears the group's references and deletes their data, fields sharing the same rid included; it asks for Clear and has no Undo.

What repair preserves​

A repair rewrites only the entry's class, namespace and assembly; its data and rid stay. When the group's fields have different types, the pick may not fit every entry: incompatible ones become null on reimport.

The summary after a rewrite has Undo: it restores the old class on entries that still hold the new one. It is gone after Rescan, closing the window or a domain reload; Edit → Undo does not revert a rewrite.

Prefab instance overrides​

A missing class set through a prefab instance override — in a variant, a nested prefab or an instance in a scene — is listed in a separate Prefab instance overrides card.

Prefab instance overrides card with a missing GhostRailgun in the EliteLoadout variantPrefab instance overrides card with a missing GhostRailgun in the EliteLoadout variant

Fix all, Smart Fix, Migrate all and <None> do not rewrite these entries: pick a new class on the instance in the Inspector, or revert the override. Asset References does not show references that exist only in overrides.

Asset References: inspect one asset​

Assign a saved prefab, ScriptableObject or scene to the field next to Rescan, or click an entry row in Project References.

Asset References with a missing GhostCrossbow, a SHARED Pistol and an orphaned Railgun entryAsset References with a missing GhostCrossbow, a SHARED Pistol and an orphaned Railgun entry

LabelMeaning
Band with Fix Missing ▼The stored class is not found; the button opens the class picker
Smart Fix → Pistol rowA class picked as by Smart Fix in Project References
Migrate → Crossbow row under a Fix ▼ bandThe class was renamed with [MovedFrom]: the row writes the new name, Fix ▼ picks a different class
Band with Change ▼, Assign ▼ or Assign Required ▼Changes the class of a healthy reference, fills an empty or required field; the asset is saved at once
SHAREDSeveral fields point at one instance; matching colours mark the connected fields
OrphanedAn entry no field points at; Clear deletes it from the file, without Undo

Fix Missing, Smart Fix and Migrate write the class to the file at once, without confirmation, and Edit → Undo does not revert it.

GhostWeapon is repaired as Pistol in Asset ReferencesGhostWeapon is repaired as Pistol in Asset References

Migrations with MovedFrom​

When CrossbowLauncher is renamed to Crossbow with [MovedFrom], Unity loads the old references itself. Migrate all writes the new name into the files so the attribute can be removed:

In the file — before Migrate allAfter
type: {class: CrossbowLauncher, …}type: {class: Crossbow, …}

A group becomes a pending migration only when exactly one class that fits the field lists the old name in [MovedFrom] and the stored class is not a closed generic; the build checks do not count such a group as missing.

Remove [MovedFrom] only when no file stores the old name any more. Migrate all does not rewrite it:

  • in prefab instance overrides;
  • in open, unsaved and locked files, see limitations;
  • in Excluded scan folders;
  • in binary assets and Git LFS files that were not fetched;
  • in files outside Assets/.

Pre-build checks​

The Build / CI gate setting picks how strict the check is:

ModePlayer buildStandalone CI run
OffSkips the checkNo scan and no report, an older report stays; exit code 0
WarnWarns and keeps buildingReport and violations in the log; exit code 0
FailMissing types stop the buildReport; exit code 1 on violations

The build checks every asset under Assets/, not only what goes into it: in Fail mode an unused prefab stops it too — exclude such folders with Excluded scan folders.

What each run checks​

RunMissing typesEmpty fields with Required = true
Project References → Scan ProjectYes, with pending migrationsUnless the mode is Off, as a Required violations group
Asset ReferencesYesYes, in any mode
Player buildUnless the mode is OffNo
CI without -srGateRequiredUnless the mode is OffNo
CI with -srGateRequiredUnless the mode is OffUnless the mode is Off

Required violations group: an empty _primary field in two prefabsRequired violations group: an empty _primary field in two prefabs

A field is made required with [TypeSelector(Required = true)]; see Required field. In scenes the Required check has limitations.

Running in CI​

Unity -batchmode -projectPath . \
-executeMethod \
Aspid.FastTools.SerializeReferences.Editors.SerializeReferenceCiGate.RunCheck \
-srGateReport SerializeReferenceGateReport.txt \
-srGateRequired -srGateFail

Exit code 2 means the check itself failed.

Command-line flags​

FlagBehaviour
-srGateReport <path>Report path from the project root, SerializeReferenceGateReport.txt by default; the folder must exist, the file is overwritten
-srGateRequiredAlso checks unset fields with Required = true
-srGateFailUses Fail instead of the project's mode, even Off
-srGateWarnOnlyUses Warn instead of the project's mode, even Off; takes precedence over -srGateFail if both are passed

Report​

The report starts with a header:

# SerializeReference Gate Report
# Violations: 2
# Not scanned (not text YAML): 2
# Binary Assets/Legacy/OldLoadout.prefab
# LfsPointer Assets/Levels/Arena.unity

Skipped files do not change the exit code.

Then one line per violation, tab-separated:

KIND assetPath fileId rid className fieldPath origin
FieldContents
KINDMissingType or RequiredUnset
assetPathFile path
fileIdHost object ID within the file; for a prefab instance override, the ID of the prefab instance
ridManaged-reference ID; in RequiredUnset rows, -2 for an empty [SerializeReference] and 0 for a string or SerializableType
classNameStored class name for MissingType
fieldPathRequired field path; for a MissingType override, the overridden field; otherwise empty
originoverride for a type set by a prefab instance override; otherwise empty

In Asset References, find an entry by its rid, and a RequiredUnset row with rid 0 by its fieldPath; an override row is in the Prefab instance overrides card of Project References instead.

Settings​

Every setting is in Tools → Aspid 🐍 → FastTools → Settings; the shared ones are also in Project Settings → Aspid.FastTools → SerializeReference, the personal one in Preferences → Aspid.FastTools → SerializeReference.

SerializeReference section of the Settings tabSerializeReference section of the Settings tab

SettingDefaultWhat it does
Build / CI gateWarnSets how strict the pre-build check and CI are
Excluded scan foldersNo foldersFolders inside Assets/ that Project References, the build and CI checks and breakage detection skip
Auto de-alias duplicated list elementsOnGives a duplicated list element its own instance instead of a shared rid
Breakage detectionOnAfter scripts or assets change, reports newly missing references with a notification and in the Console

Breakage detection is kept locally in EditorPrefs; the other settings live in ProjectSettings/SerializeReferenceSharedSettings.asset, shared by the team and CI.

Limitations​

WhereLimitation
Open scenes, Prefab Mode, unsaved and locked filesRewrites skip them: save and close the file, or repair the field with Fix in the Inspector
Scenes and fields under a missing parent referenceAsset References changes only missing types
Required in scenesFields inside managed references, collections and prefab overrides are not checked

Package sample​

Missing types, a [MovedFrom] rename and a shared reference for both tabs are in the assets of the SerializeReferences sample.