Search Issue Tracker

Feature Request

Feature Request in 2020.3.X

Votes

0

Found in

2020.3.38f1

Issue ID

UUM-14377

Regression

No

FindPropertyRelative call fails if performed on a type contained within an AssemblyDefinition file

Serialization

-

Steps to reproduce:
1. Open the attached user's project "1339919_FindPropertyRelative.zip"
2. Click on Collection under "Assets/1339919/", observe its List<Element> contains an ElementA and an ElementB
3. Deselect Collection
4. Drag "Assets/1339919/Asmdef/Runtime.asmdef" into "Assets/1339919/Scripts"
5. Drag "Assets/1339919/Asmdef/Editor/Editor.asmdef" into "Assets/1339919/Scripts/Editor"
6. Let Unity recompile
7. Select Collection
8. Observe error. "Unknown managed type ElementA"

Reproducible on: 2020.3.38f1
Not reproducible on: 2021.3.8f1, 2022.1.15f1, 2022.2.0b8, 2023.1.0a11

Notes:
- In the Assets folder is a ScriptableObject called Collection. This contains a List<Element>, decorated with [SerializeReference] attribute
- Element is an abstract base object with two inheritors, ElementA and ElementB, which also define their own data
- There is a custom PropertyDrawer called ElementDrawer which runs on both ElementA and ElementB
- There is a custom Editor for the Collection, which is not important and simply allows us to add ElementA and ElementB objects to the List<Element>

  1. Resolution Note:

    When refactoring, changing class name, namespace or assembly name for a SerializeReference instance class you would need to annotate the class with the MovedFrom attribute in order to let the serialization system know that the class changed assembly:
    You can do this by adding the MovedFrom attribute on a class, you can use it to specify a namespace change or a combination of classname, namespace, assembly.
    For namespace:
    [MovedFrom("Former.Former.Namespace")]
    For combination:
    [MovedFrom(false,string sourceNamespace = null, string sourceAssembly = null, string sourceClassName = null)]
    The first argument specifies if it is to be used by the api updater or serialization system. False means serialization system in which case you can use any combination of the other arguments.
    Also the error handling for when a type is missing has been improved in 2021.2
    https://blog.unity.com/technology/serializereference-improvements-in-unity-2021-lts

  2. Resolution Note (2020.3.X):

    When refactoring, changing class name, namespace or assembly name for a SerializeReference instance class you would need to annotate the class with the MovedFrom attribute in order to let the serialization system know that the class changed assembly:
    You can do this by adding the MovedFrom attribute on a class, you can use it to specify a namespace change or a combination of classname, namespace, assembly.
    For namespace:
    [MovedFrom("Former.Former.Namespace")]
    For combination:
    [MovedFrom(false,string sourceNamespace = null, string sourceAssembly = null, string sourceClassName = null)]
    The first argument specifies if it is to be used by the api updater or serialization system. False means serialization system in which case you can use any combination of the other arguments.
    Also the error handling for when a type is missing has been improved in 2021.2
    https://blog.unity.com/technology/serializereference-improvements-in-unity-2021-lts

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.