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
- Extended component titles exceed the window's display boundaries
- Light is not applied properly to Terrain Details when using Light Layers
- Opening reference for XR component redirects to a missing page
- [Android]Crash on PersistentManager::GlobalToLocalSerializedFileIndex(SerializedObjectIdentifier const&) when building the Android Player
- [Android] The Video Player stops playing at different points when Skip On Drop is enabled
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'.