Serializable Types
A type as an ordinary field: Unity saves it, and the Inspector lets you pick it from a list.
Quick start
| Before — Unity API | After — FastTools |
|---|---|
| |
[TypeSelector] sets the selection settings: Allow = TypeAllow.None leaves only concrete types in the list.


Which wrapper to use
| Task | Field |
|---|---|
| Store a type, including DLL, nested or generic types | SerializableType, SerializableType<T> |
| Keep the selection when your script is renamed | SerializableMonoScript, SerializableMonoScript<T> |
The T variant offers only types compatible with T in the picker.
SerializableType
SerializableType stores an assembly-qualified name: the type name together with its assembly. Set a default in code:
[SerializeField]
private SerializableType<Weapon> _primaryWeapon = new(typeof(Sword));
Wrappers that store the same type name are equal, so they work as Dictionary and HashSet keys. SerializableMonoScript follows the same rule; == compares references.
Missing type
After a class, namespace or assembly rename, the stored name no longer resolves: the field shows <Missing …> with a Missing type notice under it. The caption gives the type name without its assembly; the tooltip gives the whole stored name.
.Typereturnsnull.AssemblyQualifiedNameandToString()keep the old name.


Fix opens the type picker, and the type you pick replaces the stored name. When the class only moved to another namespace or assembly and exactly one compatible type has its name, the notice also offers it, for example → Spear. The notice compares class names and does not read [MovedFrom], so a class renamed with that attribute gets no suggestion: choose the new class with Fix.
Project References finds every missing name in the project and repairs them in groups. The build check and breakage detection report new ones.
Empty field
Test an unset field with field is null || field.IsEmpty, not field == null alone:
- Loaded from an asset, a scene or a prefab, a field holds a wrapper, empty when nothing is picked.
- On an object created in code (
AddComponent,ScriptableObject.CreateInstance), a field isnulluntil Unity serializes the object.
IsEmpty and IsMissing tell the states of a wrapper apart:
| State | Type | IsEmpty | IsMissing |
|---|---|---|---|
| A type is picked | the type | false | false |
| Nothing is picked | null | true | false |
| The stored name no longer resolves, a missing type | null | false | true |
SerializableMonoScript
SerializableMonoScript remembers the script asset itself, so the selection survives a script rename. Pick the type in the Inspector or drag a .cs file from Project onto the field.
After renaming Sword.cs → Blade.cs | SerializableType | SerializableMonoScript |
|---|---|---|
.Type | null, a missing type | Blade, in Play Mode too |
| Stored name | Sword | Blade once the asset is saved again |
Limitations:
- only a top-level, non-generic class can be picked: one declared in a
.csfile of the same name, or one derived fromMonoBehaviourorScriptableObjectin a DLL; - there is no public constructor, so the field cannot be created in code.
The link breaks, and the field shows a missing type with the same notice, when:
- the class is renamed without its file;
- the file is renamed outside Unity without its
.meta; - a class from a DLL is renamed or moved to another namespace: Unity identifies its script asset by namespace and class name.
Types in a player build
In a player, both wrappers resolve the stored type name. If a class is used only through this selection, Managed Stripping Level Medium or High strips it: .Type returns null and IsMissing becomes true, although the editor resolves it. Minimal and Low keep it.
To keep the class at Medium or High:
- Mark the class or its constructor with
[Preserve](UnityEngine.Scripting). - List the class, or its whole assembly, in
link.xml. - Mark your interface with
[RequireImplementors]or your base class with[RequireDerived]to keep all its implementations: the field must be aSerializableType<T>of that interface or base class.
Package sample
For Inspector selection of enemy types and spawn patterns, see Types.

