Unable to Hide UI


I am having trouble hiding my UIs. My set up is the same as “Making a Simple Game: Keepy Up”. I have a “game” script that handles the UI hiding and appearing:

The code works when I call the “start” function, it hides uiMenu and show uiInGame. However, when I call the function “backToMenu”, the uiMenu show up, but the uiInGame doesnt disappear.

My uiMenu code is:

My uiIngame code is:

Any clues why my uiMenu successfully hid and appear while my uiIngame is not?

Any help would be very much appreciated!

Thank you!

Can you share a link to the project please?

I see that you set the button opacity to 0 when you disable the uiGame but don’t set it back to 1 on enable.

1 Like

Sorry please ignore that button opacity line, I was just trying to try out different things to see if making the button opacity =0 would fix it but it doesnt.

This is the link to my project:https:

Thank you for your help!

Could anyone help me with this please? I am scratching my head not figuring out where this goes wrong :cry:

I just removed the script on the uiingame entity and it started working correctly :slight_smile:

1 Like

Oh so you think thete is something wrong in my initialization in uiingame?

I don’t see anything wrong there. The issue is weird. It shouldn’t happen but now we know it can be resolved through removing script so just add script somewhere else and it should work.

1 Like

Thank you saif! It is weird. I have a few buttons that i want the user being able to click in the uiIngame, but i guess i can figure a workaround, probably having an event listener in the root instead of the UI.

Thank you for your help!

1 Like

No Problem :smiley: I guess it’s a bug because i tried every possible solution but wasn’t working. Anyhow, glad it resolved your problem :slight_smile:

1 Like

How do you reproduce your issue? It’s a huge project.

I havent fixed it yet. If you click on play, you will see on the top right corner, there is a button. If you click on that button it supposes to bring you back to the menu screen and the button itself disappear. In my case you can see the menu appears, but the button is still there and never goes away

You may have found a weird bug in the engine.

Since you are disabling the whole entity for each screen, you don’t need to disable the button entity itself. Nor do you have to on/off the events because the button entity is part of the screen.

The following code is fine:

var UiIngame = pc.createScript('uiIngame');

UiIngame.attributes.add("button1", {type: "entity"});

// initialize code called once per entity
UiIngame.prototype.initialize = function() {
    this.button1.element.on("click", this.start, this);

UiIngame.prototype.start = function () {

This will get you around this bug.

1 Like

You managed 6 min faster than me :smiley: Was about to post the same solution. I did spend a lot on the bug though. Its weird. I will make a small repro project for bug report.


Awesome! Thank you so much guys for your help! Glad I could help with the discovery of the bug haha