Search Issue Tracker
By Design
By Design in 6000.4.X
Votes
0
Found in
6000.0.61f1
6000.2.11f1
6000.3.0b9
6000.4.0a4
Issue ID
UUM-126011
Regression
No
Custom Inspector throws a NullReferenceException error even when using #if UNITY_EDITOR preprocessor directive
How to reproduce:
1. Open the attached “IN-122461.zip“ project
2. Enter Play Mode
3. Select the “Inspector” GameObject
4. Observe the Console
Expected result: No error is thrown
Actual result: NullReferenceException Error is thrown
Reproducible with: 2023.1.0a1, 6000.0.61f1, 6000.2.11f1, 6000.3.0b9, 6000.4.0a4
Reproducible on: Windows 11 Pro (24H2)
Not reproducible on: No other environments tested
Workarounds:
- Have no .asmdef files in your Assets/ directory
- Create a .asmdef file in Assets/Editor that is only applied to “Editor”
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
- Frame Debugger is not disabled when switching Scenes if the Frame Debugger window is not open during the transition
- Standalone Profiler Targets another Project if a Standalone Profiler was launched in it before when switching between Edit or Play Mode Targets
- Crash on ForwardRenderLoopJob when opening a specific project
- [Android] Memory leak and eventual crash on Snapdragon 8 Gen 1+ devices when a Clear Pass is executed after Framebuffer Fetch
- PhysicsRaycaster ray length is incorrect when casting from rotated Camera
Resolution Note:
Serialized asset reference aren't designed to work when set on inspector scripts. The recommended way to get access to the visual tree from the CreateInspectorGUI() call would be to use the asset database:
var visualTree = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/VisualTree.uxml");
Resolution Note (6000.4.X):
Serialized asset reference aren't designed to work when set on inspector scripts. The recommended way to get access to the visual tree from the CreateInspectorGUI() call would be to use the asset database:
var visualTree = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/VisualTree.uxml");