Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

[2017.2.b03] Issue with SetActive

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

  1. nhold

    nhold

    Joined:
    May 2, 2017
    Posts:
    50
    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.

    Workaround:

    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: https://forum.unity3d.com/threads/instanced-ui-not-begin-shown.482247/
     
    Last edited: Jul 17, 2017