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
- Crash on tlsf_free when triggering a call to FontEngine.LoadFontFace for the default Editor font while Glyphs are being generated
- No character limit when creating a new Scene with excessively long name, Editor can be forced to crash
- Reflection probe not applied when viewing objects up close at certain angles with "Forward+" Rendering Path
- URP Decal Projector flickers/glitches when added to Cube or Quad GameObjects as a Component
- Text "Outline Width" is not shown in the Text Property Preview window in UI Builder when the Text Size is smaller than 19px
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'.