Search Issue Tracker
By Design
Votes
0
Found in
2022.3.58f1
6000.0.39f1
6000.1.0b7
6000.2.0a4
Issue ID
UUM-97834
Regression
No
Serialized Field's type is not updated to the correct concrete type when the referenced object is restored via the undo system or is deleted
Reproduction steps:
1. Open the attached “UndoSerializedFields” project
2. Open the “Assets/BugReport/New Scene” Scene
3. In the Hierarchy window, select “ReferencingComponent” GO
4. In the Inspector window, observe “My Reference Type” variable
5. In the Hierarchy window, delete “GameObjectToReference” GO
6. Repeat steps 3 and 4
7. Toggle the “Some Useless Toggle” property and repeat step 4
8. Undo actions (cmd + z) until “GameObjectToReference” GO is restored
9. In the Hierarchy window, select “ReferencingComponent” GO and repeat step 4 and 7
Expected result: The reference type is updated instantly to “Object” type after deleting and to “GameObject” type after restoring the “GameObjectToReference”
Actual result: The reference type is only updated when a forced deserialization occurs (e.g., toggling an Inspector property)
Reproducible with: 2022.3.58f1, 6000.0.39f1, 6000.1.0b7, 6000.2.0a4
Reproducible on: macOS Sequoia 15.3.1 (M1 Max), Windows 11
Not reproducible on: No other environments tested
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Non-multisampled texture binding errors are logged when running the DepthBlit URP scene with MSAA enabled on Vulkan
- The Editor does not recognize code errors in generic classes when using C# Source Generator to generate serialization code
- NullReferenceException is logged when undoing Deletion of a Visual Query Block of a Search Expression
- “Unsupported type MinMaxCurve” error and “Could not register property modification for animation binding…” warnings are thrown after moving playhead when Particle System Property is added to Animation window
- Nested LocalizedStrings can not query local variables
Resolution Note:
For accurate multi-object editing and automatic undo handling the object needs to be retrieved through SerializedObject/SerializedProperty, as this will achieve the deserialization of the latest object that the toggle is forcing.
This object reference can then be used to get the concrete type as it will have had delete/undo updates applied.
Example:
SerializedObject serializedMyReference = new UnityEditor.SerializedObject(this);
Object myReferenceObject = serializedMyReference.FindProperty("myReference").objectReferenceValue;
myReferenceType = myReferenceObject != null ? myReferenceObject.GetType().Name : "NULL";