Info
[SerializeReference] data stores the class name, namespace and assembly. Rename or move the class and the data is lost
- Module
Polis.Core.SerializedTypeMigration. Don't use [MovedFrom] for this, use [FormerlySerializedType] and the migration tool
Usage
[FormerlySerializedType(0, "Foo")] // Old.Ns.Foo
[FormerlySerializedType(1, ns: "Old.Ns")] // Old.Ns.Bar
public class Bar { } // New.Ns.Bar
- One attribute per move.
version is unique per type, lower = older. Never delete old ones
- Null part = same as the next newer version.
"" means no namespace. Nested class: "Outer/Inner". Also works for types used as generic arguments
- Polis / Serialized Type Migration
- Scan lists pending migrations, orphans (no type and no declared old name), binary assets and errors
- Apply rewrites asset files on disk. Needs Force Text serialization, no play mode, saved scenes. Commit first
- Apply Automatically rewrites as soon as old names appear (off by default, a branch switch becomes a big diff)
MigrationWatcher logs problems after recompile and when assets with old names are imported
Gotchas
- Assets are rewritten by the tool, not at load time. Run it after a rename, before committing