1. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  2. Unity 2017.2 beta is now available for download.
    Dismiss Notice
  3. Unity 2017.1 is now released.
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Reddit AMA with Adam Myhill on Cinemachine, Thurs July 27 - 10AM PT. More info.
    Dismiss Notice
  6. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  7. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    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:
    8
    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