How can I set up an in-game menu?
So I'm trying to make it so if I click the "Menu" Button in the top left corner, a menu comes up. Then on that menu, you can click "Resume" or "Exit". Here's what it looks like. http://prntscr.com/8utezl
I've been trying to get a working script for it, here's what I have so far, but I'm having issues. http://prntscr.com/8utfeq
I managed to get a Main Menu working last night, but I can't figure out how to get this in-game menu working. I would like the "Menu" button to open up the menu, and the "Resume" button to close the menu, and the "Exit" button to go back to the main menu.
Any help would be greatly appreciated :P
Tip: Please don't paste code as an image. Put it in the post or if it's lengthy, provide a link to pastebin or some other place where we can get the code. I don't want to install OCR software to get the text to my clipboard. Doing so will decrease friction for people who want to help you and you're more prone to get an answer.
Answer by Statement · Oct 24, 2015 at 10:56 PM
If you want to set it up with the inspector, select the button, add On Click event handlers and route them to your canvas / GameObject.SetActive.
If you want to set up callbacks with code:
menuButton.onClick.AddListener(() => MenuCanvas.SetActive(true));
resumeText.onClick.AddListener(() => MenuCanvas.SetActive(false));
exitText.onClick.AddListener(() => GameUICanvas.SetActive(true));
Or something similar...
Your answer
Follow this Question
Related Questions
Pause menu done exactly according to tutorial doesen't work 2 Answers
Ship selection menu during game 0 Answers
UI Dropdown problem. 1 Answer
How to get access to other's script var with increment? 0 Answers
Making UI block rays with touch inputs 0 Answers