- Home /
How To Hide Game Objects That Aren't In Pause Script
Hey guys, I need to hide my touch buttons for an android phone when the game is paused, I have a pause script fully functional with menus but when the gui comes up the game buttons can still be pressed, which allows the player to accelerate to maximum speed or turn left and right even while paused
Does anyone know how I can hide 5 objects when paused and make them re-appear when not?
I was thinking of using tags, I've seen it done in JS, but I use C#
Thanks in advanced!
wait are you trying to hide GUI or objects that are interactive? With GUI just stop calling them in OnGUI, for interactive objects, disable all their scripts or at least limit their functions globally.
Objects that are interactive.
I have my touch buttons as interactive objects and when one of those objects are pushed (the pause button) the GUI will pop up.
I want the interactive objects to then disappear at that same moment.
Ok, how would I disable them like that?
Answer by BobbyDoogle · Mar 16, 2014 at 07:27 AM
I think there are multiple ways to accomplish this. I implemented a pause system in a 3d game via C# recently and got good results with
if (paused) {Time.timeScale=0;}
Then set Time.timeScale back to 1 when you leave pause.
Another approach would be in the scripts that allow control, reference your pause script and disable them when paused via their individual scripts.
The second approach seams like what I need to do, how could I achieve that?
by making a reference to those scripts from your pause script , then disabling them in code. references can be made by using the Gameobject.Find("myObjectName"); and gameobject.GetComponent("myScriptnameThatisntthepausescript") as myScriptnameThatisntthepausescript; type methods.
after that the control structure is something like this.
if(PauseScript.paused) {
render.enalbed = false;
RuntouchFunction = false; //the bool that switches your touch functions
}
each of your script will check if its the game is paused after anyof them are clicked or if you want on Update.
Do you know the codes for that? or is the first part done in the inspector?
Hey where do these go?: Gameobject.Find("myObjectName"); and gameobject.GetComponent("myScriptnameThatisntthepausescript")
like, above the start();, in the update();.. where?
Your answer
![](https://koobas.hobune.stream/wayback/20220613140348im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to Hide the GUI when time.scale = 1 again 1 Answer
Pause menu script, mouse not hiding 1 Answer
Pause Menu Problem 1 Answer
NGUI panel wont hide 2 Answers
hide child object script - help 1 Answer