MixedRealityToolkit-Unity
MixedRealityToolkit-Unity copied to clipboard
StateVisualizer prefab variants can corrupt prefabs
Describe the bug
When making a prefab variant and changing/adding effects, you can get into an inconsistent state where the local copy of the repo + with your Library cache makes the correct behavior appear, but clearing the Library and/or checking out the same code into a new project results in corrupted prefabs.
To reproduce
Steps to reproduce the behavior:
- Make prefab variant of button
- Add/modify effects
- Save, commit changes
- Clear library
- Prefabs corrupted
Expected behavior
Prefabs should appear as they do with or without clearing the Library and should behave consistently across projects.
@JonathanPalmerGD
Katie H and I determined this is a Unity YAML serialization bug related to immutable packages wherein prefab variants that are variants of prefabs in immutable packages will have the incorrect YAML format serialized to disk.
Further investigations:
-
The 2021 serialization, when adding a new entry to a list and then immediately defining it (this example resizes from 1 -> 2, and defines the new object), does this:
- Overrides size of list:
propertyPath: ListOfReferences.Array.sizevalue: 2 - Defines new RefID inline:
propertyPath: ListOfReferences.Array.data[1]value: LONGNUMBER - Immediately, for subsequent entries in the yaml, begins referring to this entry by the LONGNUMBER.
- Specifies the type and assembly:
propertyPath: managedReferences[LONGNUMBER]value: MyAssembly MyNamespace.MyType - Specifies the new value of this item:
propertyPath: managedReferences[LONGNUMBER].SomeValuevalue: 42069
- Overrides size of list:
-
The 2020 serialization, which is observed in MRTK's override of Action Button on Empty Button, appears as follows
- Overrides size of list:
propertyPath: ListOfReferences.Array.sizevalue: 2 - Does not define a new refid.
- Specifies assembly and type of the item:
propertyPath: ListOfReferences.Array.data[1]value: MyAssembly MyNamespace.MyType- Notice: the property path is NOT a RefID, it's a path!
- Specifies new value of the item:
propertyPath: ListOfReferences.Array.data[1].SomeValuevalue: 42069- Like above, the property path is NOT a RefID, it's a path!
- Overrides size of list:
When the 2020 packages are consumed in 2021 project, Unity 2021 tries to make a 2021-formatted override on a 2020-formatted asset, which causes the problem. It tries to refer to the serialized item by managedReferences[LONGNUMBER] even though LONGNUMBER does not actually exist in the base asset.
@shaynie We'll might be removing support for 2020 with PR 11345. Can you investigate the impact here.
https://github.com/microsoft/MixedRealityToolkit-Unity/pull/11465 Upgrades Unity to 2021.3 and re-serializes all prefabs.