Reputation: 127
I been trying to make an overlay menu just like the one in video below(crossy roads) and my setup is also pretty similar with button in corners and live game screen. What I tried was I used an UI image and made it setActive using a button and decreased the alpha of it. It looks pretty same but
1.)my buttons are also overlayed by the image
2.) When I click on my buttons, my character moves, I don't want this to happen. It should happen only when I click somewhere else and then the buttons disappear.
3.) You can see how even on touching the character doesn't move in the behind screen, that's what I wanna do.
I searched all over the Google but can't seem to find the answer that I want. I want to put my game characters in the middle just as in the video. Any help is really appreciated I am kinda new to unity. Thanks everyone :)
Upvotes: 2
Views: 1781
Reputation: 155
I will try my best to answer. This is my first answer on StackOverflow, so please forgive me, if i get something wrong.
1.) The order of drawing the UI elements is from top to botton of your hierarchy. So if you an Image GameObject above a button in you hierarchy, then the button should not get obstructed by the image, which should be what you want, if I understand you correctly
2.) You could have a boolean variable which tracks, if the player menue is opnen (or check if the UI GameObject is active) and if so don't check in your player movement script for new locations / dont move the player. You could also add a CanvasGroup Component to the UI GameObject and set "interactable" and "Blocks Raycasts" to true
3.) This should also be fixed by that, what i explained in 2.)
Greetings and good luck!
Upvotes: 1