Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

[2017.2.b03] Issue with SetActive

Discussion in '2017.2 Beta' started by nhold, Jul 17, 2017.

  1. nhold


    May 2, 2017
    I have a basic setup for a prototype:

    1. I have a Prefab instance that starts inactive in the scene (The prefab is also inactive)
    2. I enable it when pressing a button to show\hide it (Which just uses SetActive(true), SetActive(false).
    3. In previous versions of Unity this worked fine (2017.1 The 2D experimental version)
    4. If after I click the button (Which enables the GameObject) and I add an image component to one of the free GameObjects in the prefab instance hierarchy it will show and work as expected after that (Hiding and showing correctly.


    A way to 'fix' this is to ensure everything is enabled by default and wait for the end of frame after any parents SetActive(true) then manually set them to false. Although you cannot only wait for end of frame if the parents start active (I.e in IEnumerator Start()) as that will crash the editor you must run a seperate coroutine from start.

    EDIT: This issue is exactly the same as this:
    Last edited: Jul 17, 2017