Search Issue Tracker

By Design

Votes

1

Found in

2019.3

2019.3.10f1

2020.2

Issue ID

1241777

Regression

No

Using [SerializeReference] with an interface object results in a missing input field in the Inspector

Serialization

-

How to reproduce:
1. Open the user-supplied project ("testproj.zip")
2. Open the "SampleScene" and inspect the "GameObject" GameObject
3. Navigate to the "Test User" Script Component in the Inspector view and observe it

Expected result: the interface object "Test" has a reference input field
Actual result: the interface object only has its label and no input field for a reference

Reproducible with: 2019.3.15f1, 2020.1.0b11, 2020.2.0a13
Could not test with: 2018.4 due to [SerializeReference] not being present

  1. Resolution Note (2020.2.X):

    SerializeReference are aimed at allowing referencing Serializable C# classes not derived from UnityEngine.Objects and allowing those to be saved by reference rather than by value on a single ScriptedObject/MonoBehaviour instance. In the provided use case the MonoBehaviour was deriving from an interface and a SerializeReference field of that interface types was used. In order to achieve what you aimed you can use a specific MonoBehaviour type on a regular SerializedField.By default objects are saved as references in Unity in such scenario case. Hope this helps. For extra information on SerializeReference https://docs.unity3d.com/ScriptReference/SerializeReference.html

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.