- Home /
Time.timeScale = 0 did not prevent click
Holla Uniters ! i try to figure out how to pausing a game.. after awhile of searching i found out there are a lot of way to do it.. but i comes up with the easiest(i think) way to do it.
So, part of my code is
function Start{
Time.timeScale=0
}
function OnGUI{
If(GUI.Button(new Rect(100,100,50,50),"next")){
Time.timeScale=1;
}
}
ok, it works perfectly, but.. in the background of this i have some GUI Button attached to the screen, and when i press "Play" i can still press the GUI Button, and is affecting game, although it doesn't move the player.. but after i press "next" my character start moving because of action i do before.. could anybody help me?
How exactly i could make, say, i want to blackout all the back screen OR i want so that player couldn't touch anything until they press "next"
Answer by HappyMoo · Jan 19, 2014 at 12:08 PM
Your code shouldn't work. This does nothing:
Time.timeScale=1;
If you don't want some things to be possible, don't allow them or hide them if timescale==0. Unity doesn't do that for you, or you wouldn't be able to leave pause again if all Buttons stopped working.
http://docs.unity3d.com/Documentation/ScriptReference/Time-timeScale.html
so what i should do , is play the logic of hiding and unhiding objects i dont want to interact with?
but, i just too confused for my code aldy to how to hide them.. i mean like if i have button and drawtexture, if i press the button, i want the button to go away to underworld and only appear the drawtexture, so its like
if(GUI.Button(Rect(0,0,10,10), "press")){
GUI.DrawTexture(new Rect(0,0,200,200),someTexture)
//also disable the "press" Button.
}
if i just use boolean to enable and disable the GUI.Button won't it disable the DrawTexture also? sorry if i ask silly thing, but i just can't get it on my $$anonymous$$d about the logic :(
if you go into pause, just set pause$$anonymous$$ode=true and then have some code depend on that...
if (pause$$anonymous$$ode)
{
// show pause menu etc.
} else {
// normal game logic here
}
Your answer
