Search Issue Tracker
Won't Fix
Won't Fix in 2023.3.X
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
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
- [Tile Palette] Sprites not rendering when brush tool "Paint a filled box with active brush" is used for the first time
- Adding available Nodes with longer names in Fragment Context window overflow Fragment Context window in Shader Graph
- "Layer Palette Profile" Asset is automatically applied to the second Terrain but doesn't load any layers
- "Terrain Tools" shortcut conflicts with the Overlays shortcut by default
- Longer Shader Graph Property Reference names breaks VFX Graph Output Particle Node
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;
}
Resolution Note (2023.3.X):
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;
}