Search Unity

Question UI object is not rendering when changing scenes

Discussion in 'UGUI & TextMesh Pro' started by NeilB133, Feb 19, 2023.

  1. NeilB133

    NeilB133

    Joined:
    May 30, 2022
    Posts:
    210
    So you'll see in the clip below, when I'm in the scene the black circle transition object is there, then it goes to the 3,2,1 and then the level starts. However when I go to this scene from another scene, it appears that the object is still in the hierarchy, but it just doesn't seem to render, it just shows the 3,2,1 (which is paused before it starts because it executes from a coroutine).

    I'm not sure if it has anything to do with the fact that it's using a Mask. In order to create this I simply followed this guide by CodeMonkey:




    Hope this question is okay here. Any help would be great :)
     
  2. NeilB133

    NeilB133

    Joined:
    May 30, 2022
    Posts:
    210
    Noticed that others in the YT comments were having issues with this implementation when changing scenes.

    This approach may cause some issues. For example: when changing scenes (when it's DontDestroyOnLoad) if the object (Image) is not focused - it disappears. Therefore it doesn't work properly for scene changing (all platforms). Tested on Unity 2020.2.1f1

    Weirdly enough, to fix this, in my code in the update function when the logic runs to start the level, I put:

    Code (CSharp):
    1.  cutoutMaskUI.enabled = false;
    2. cutoutMaskUI.enabled = true;
     
    Last edited: Feb 19, 2023