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
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
- Channel remapping dropdown in the Terrain Layer does not open when clicked on the title
- The Editor freezes indefinitely when a large number of elements are entered in the Subgraphs or Categories lists
- Some Visual Effects package Assets links to documentation are not working
- Heatmap asset’s documentation button in the Inspector window leads to “Sorry... that page seems to be missing!” page when clicked
- Crash on MonoBehaviour::CallMethodIfAvailable when performing various actions
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;
}