Search Issue Tracker
By Design
Votes
0
Found in
2018.4
2019.4
2020.2
2020.2.1f1
2021.1
2021.2
Issue ID
1308575
Regression
No
GameObjects could not be referenced in the Inspector when there is a class named GameObject in the project
How to reproduce:
1. Open attached project "case_1308575_gameobject.zip"
2. Open "SampleScene" scene
3. Select "Test" GameObject in the Hierarchy window
4. Try to reference any GameObject for the "Testing" variable
Expected result: the selected GameObject is referenced
Actual result: the selected GameObject is not referenced
Reproducible with - 2018.4.30f1, 2019.4.17f1, 2020.2.3f1, 2021.1.0b3, 2021.2.0a3
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
- Shader warning in 'Hidden/Core/DebugOccluder' thrown after building High Definition 3D Sample Template
- Audio Mixer “+” buttons overlap with UI when the Audio Mixer window layout is set to Horizontal
- "Clear" button in the "Set project display name" closes all the pop-up instead of clearing just a name from the field
- Video Player renders no video on specific devices when using Vulkan
- The Editor slows itself down by showing tons of warnings when the majority of TransformAccessArrays content are NullRefs
Resolution Note:
The object field in the inspector is expecting an instance of the custom `GameObject` class rather an instance of a `UnityEngine.GameObject`. Being explicit with the desired type would resolve this issue; `public UnityEngine.GameObject m_GameObject`, another solution would be to wrap the custom GameObject class within a namespace:
namespace Custom {
public class GameObject {}
}
This would also report the following error if non-explicit usage was present when `using` both the `Custom` namespace and `UnityEngine`:
CS0104 C# 'GameObject' is an ambiguous reference between 'Custom.GameObject' and 'UnityEngine.GameObject'.