Search Issue Tracker
In Editor, SetActive(true) does not work when it is called the first time
How to reproduce:
1. Open attached project "setActiveFalse_firstTime7.zip" and scene "FloorMap00"
2. Enter Play mode
3. In Game View, press on "Asset Tracking" button
4. Observe Console window (the image SetActive(true) was called, but it never showed up)
5. In Game View, press on "X" button
6. Repeat step 3-4 (the image shows up)
Expected result: after pressing on "Asset Tracking" button the image pops up
Actual result: the first attempt of pressing on pressing on "Asset Tracking" button the image did not show up
Reproducible with: 2017.4.16f1, 2018.3.1f1, 2019.1.0a12
This is by design. gameObject.SetActive(false); is called in Start() of the MonoBehaviour that SetActive(true) is called on. First time gameObject.SetActive(false), Start() will be called and then the gameObject will be disabled immediately. The second time gameObject.SetActive(false) is called, Start() has already been called and won't be called again. So SetActive(true) works the second time because gameObject.SetActive(false) isn't called afterwards.
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
- [Interactions] Some Interactions don't have the correct startTime, time and duration in callbackContext.
- [Interactions] InputAction.CallbackContext.interaction does not hold the correct value, when it is set to Default.
- [Editor] When Preference window is open, exiting Playmode generates NullReferenceException.
- [Addressables] Models have deformations when they are imported from AssetBundle and Play Mode Script is set to Packed Play mode
- The error of " 'Light' does not contain a definition for 'SetLightDirty' " when building the project