- Home /
Clear presses from previous scene
In my first scene I have a button that causes the second scene to load. The second scene has a button in the same location. If the user is over eager (or the delay loading the second scene is over long) they might press the button multiple times while the scene is loading. As soon as the new scene finishes loading those button presses come through, but since it is a new (different) button the result is lousy.
Can I clear pending inputs when I load the new scene?
Is there another trick to prevent this behavior?
Thank you in advance for your help!
Hmm, what happens If you start the scene with the buttons inactive, then, once the scene is loaded, activate them? Or perhaps a similar trick with the UI layer?
Answer by Miizu · Oct 08, 2015 at 10:42 AM
I think you could easily fix this by just setting the button's interactable variable to false the first time they press it.
.edit
I think I understood your question incorrectly, if the problem is in the second scene, create a script that sets the same variable to true after some seconds, this way when the scene is still loading the button would not be interactable.
Thank you everyone for the great suggestions.
I ended up implementing a combination of suggestions from here. 1) On the second scene I start with the button not interactable and only set interactable to true after the scene is done loading. This seems to resolve any left over presses from before scene was loaded.
2) I also added a transition in between the two scenes. The transition starts immediately after the first button press so the user should get the feedback that something is happening and not feel a need to press the button again (even if there is a slight hiccup latter as it is loading the second scene)
Answer by HarshadK · Oct 08, 2015 at 08:30 AM
One option I would like to suggest is that once user presses the button to load the second scene then disable that button or remove it altogether from the screen so that user will not be able to press it multiple times. This will clear out the problem of user trying to press the load button multiple times. It is a very standard trick used in the websites to prevent form submissions multiple times by users since user might feel that the website is not responding or like that.
To add to it once user presses the load button and you hide or disable it, you can show a message to the user that second scene is being loaded to let them know that their input is received and system is processing it.
Answer by NDark · Oct 08, 2015 at 10:14 AM
How about try adding a state of "not press" or a timer after loading scene after before load another new scene?
If I were you, I will try these solutions...
There must be non-press state first of this trigger
After a loading scene action, there must be 1 sec duration, then able to trigger.
Use GUI Animation, everytime new scene loaded, the GUI will animate from outside of screen, make sure the user will not press the same button again.
Answer by SmileQ · Oct 08, 2015 at 07:14 AM
Dont know why this would happen.
But the first fix that came to mind was to set a one second delay after scene load before you can press the button. Or maybe less ,1/4 of a sec, just play with it.