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.
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.
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.
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.
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
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.app.fire("ui:backToMenu");
};
You managed 6 min faster than me 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.