Search Issue Tracker

Won't Fix

Votes

6

Found in

2021.3.30f1

2022.3.9f1

2023.1.12f1

2023.2.0b8

2023.3.0a4

Issue ID

UUM-47971

Regression

No

Default References of nested Serializable classes are not exposed in the Inspector

--

-

Reproduction steps:
1. Open the attached “IN-50785 Default References not exposed.zip“ project
2. Open the “SampleScene”
3. Select the “GameObject” in the Hierarchy
4. Notice that the “Mono (Script)” component in the Inspector has a Material reference from the “Nested” class
5. Select the “Mono” script in the Project window
6. Observe the Inspector

Expected result: The Material reference from the “Nested” class is exposed on the “Mono” script
Actual result: The Material reference from the “Nested” class is not exposed on the “Mono” script

Reproducible with: 2021.3.30f1, 2022.3.9f1, 2023.1.12f1, 2023.2.0b8, 2023.3.0a4

Reproduced on: Windows 11 Pro (22H2)
Not reproduced on: No other environment tested

Notes:
- Reproducible in a new project
- Adding “MonoBehaviour” inheritance to the “Nested” class exposes the Material reference on the “Nested” script but then on the “Mono” script and the “GameObject” it appears as “None (Nested)” and nothing can be referenced through it

  1. Resolution Note:

    This is by design, only objects that inherrits from UnityEngine.Object is allowed as defaults.

    The closes solution to what want is to make the Nested object inherrit from ScriptableObject and then create an instance of it (using CreateAssetMenu attribute and make an instace under Create -> Nested) and assign that instance as the Default reference to the Mono script

    [CreateAssetMenu]
    public class Nested : ScriptableObject
    {
    public Material _Material;
    }

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.