Yik Yak icon
Join communities on Yik Yak Download
i need some help. i’m making it so you can toggle the pause menu with escape in my unity game, and the script is perfect EXCEPT idk what to replace ‘gameObject’ with. does anyone know?
9 upvotes, 7 comments. Yik Yak image post by Anonymous in Gaming. "i need some help. i’m making it so you can toggle the pause menu with escape in my unity game, and the script is perfect EXCEPT idk what to replace ‘gameObject’ with. does anyone know?"
upvote 9 downvote

default user profile icon
Anonymous 1d

It’s been a little while since I’ve done any coding so I might be a bit rusty, but from what I can tell, PauseMenu.gameObject.SetActive(true) is basically just telling the program to set the PauseMenu’s attribute, known as gameObject to be true. When the gameObject is set to true, the game knows to activate the pause menu. The gameObject might be the menu’s appearance if it’s associated with any resources, otherwise it may just be an indicator of PauseMenu’s status, of being activated or not.

upvote 6 downvote
default user profile icon
Anonymous 1d

PauseMenu.game object is expecting a static object. If you have a global controller script you can initialize a pause menu game object and then reuse it, but since you want to use a global command, keeping the object static will help

upvote 1 downvote
default user profile icon
Anonymous replying to -> #1 1d

If you’re certain that gameObject needs to be replaced, then I’d look under PauseMenu, checking if it has any associated attributes or variables that are binary/boolean/whatever your language calls variables that can only be set to true or false, and that’s probably what you’re looking for. Otherwise, unless you replace it with something that’s been already established earlier in the code, it won’t work

upvote 5 downvote
default user profile icon
Anonymous replying to -> #1 1d

i attached a non-static gameobject variable to the script, will that work?

upvote 1 downvote
default user profile icon
Anonymous replying to -> OP 1d

I honestly have no idea. That all depends on a lot of things that I just don’t know about, which may be specific to your situation/program. But if you think that’s the right approach, try it and see what happens. If it works, great. If not, then you may need to try a different approach. Sorry I can’t be more help, I just can’t really say for sure if it’s right or wrong

upvote 3 downvote
default user profile icon
Anonymous replying to -> #1 1d

i think i’m heading in the right direction now. thank you!!!

upvote 1 downvote
default user profile icon
Anonymous replying to -> #2 1d

I’m it an expert in Unity though. When I was working in a game for school my friend handled menu logic

upvote 1 downvote