UI pop up issues

Hi there,

I’m having an issue with the game pop ups for our game I’m not a coder so I’m struggling with how to get more than one working within the level.

I have managed to set it up so that when the player enters a trigger box text will appear inside a speech bubble for 5 seconds to tell the player what to do.

I can’t seem to get it to work for the second amount of text and was wondering if someone could advise!

I also get an error: missing reference exeption: the object of type has been destroyed but you are still trying to access it Your script should either check if it’s null or not destroy the object

Thanks :slight_smile:

This will be due to your OnTriggerEnter still being able to access these game objects after you have destroyed them.

You probably want to put all these UI objects under the one parent object, so you only have to .SetActive() the parent and not each other object one by one.

Then when you can destroy it you can guard against it being null. Eg:

private void OnTriggerEnter(Collider collider)
{
    if (_popup == null)
    {
        return;
    }
    
    // everything else
}

Do you mean its not waiting 5 seconds, or you have a second (2nd) set of text you want to display?

Also in future please post code in code tags, and not screenshots.

It also looks like your Visual Studio is not set up correctly. You may need to specifically install the Visual Studio tools for Unity: Install & configure Visual Studio Tools for Unity | Microsoft Learn