Search Issue Tracker
GameObject reference is null when creating it inside Reset() function and assigning Script as component
How to reproduce:
1. Open attached user's project "ResetTest.zip"
2. Open "SampleScene" Scene
3. Click on "GameObject" in the Hierarchy window
4. In Inspector window, right-click on "New Behaviour Script" and choose Reset
5. Observe console
6. Remove "New Behaviour Script" component from "GameObject"
7. Add "New Behaviour Script" Script from "Scripts" folder to "GameObject"
8. Observe console
Expected results: Same Console message (Generated GameObject (UnityEngine.GameObject)) after 4th and 7th step
Actual results: Console logs out null
Reproducible with: 2019.4.16f1, 2020.1.16f1, 2020.2.0b14, 2021.1.0a8
Couldn't test with: 2018.4 (Failed to downgrade to a functioning project)
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
- Changes to instanced detail mesh material don't immediately apply
- Undo.RegisterObject or Undo.CreateObject dirties the scene, but no actual changes to Scene are made
- [Profiler] Scrubbing through filtered frames or sorting their data replaces the displayed data with duplicated data entries
- [UI Builder] It is possible to add content to parent document while editing child document in place
- EndChangeCheck is not triggered when clearing the IMGUI search field by pressing the "x" button