- Home /
What is wrong with this script?
Im trying to make a pause menu, when escape is pressed GUIText appears and your mouse gets unhidden. This does not work. Please help!
var levelToLoad : String;
var open : boolean = false;
var menu : GUIText;
var mainmenu : GUIText;
var exitgame : GUIText;
var gamebox : GameObject;
function Update(){
if(Input.GetKeyUp(KeyCode.Escape)){
if(!open){
menu.active = true;
mainmenu.active = true;
exitgame.active = true;
open = true;
gamebox.GetComponent("HideMouse").Hide = false;
}
if(open){
menu.active = false;
mainmenu.active = false;
exitgame.active = false;
open = false;
gamebox.GetComponent("HideMouse").Hide = true;
}
}
}
i have a pause menu script in c# if you want it but the mouse doesn't get gidden.
Answer by Eric5h5 · Nov 04, 2012 at 04:16 AM
Your script checks if open is false, and if so sets it to true, then immediately afterward checks if it's true, which of course it is since it was just set to true. Look into if/else. Also don't use quotes in GetComponent.
one question, when i dont use quotes, it says $$anonymous$$ identifier: 'Hide$$anonymous$$ouse'. please help
Is Hide$$anonymous$$ouse C#? If so, preferably rewrite it in JS. Otherwise put it in Standard Assets (while making sure the JS script that accesses it is not in Standard Assets). http://docs.unity3d.com/Documentation/ScriptReference/index.Script_compilation_28Advanced29.html
Your answer
Follow this Question
Related Questions
How do I change the text of a gui image text 1 Answer
Null reference exception error when using a slider 0 Answers
GUI Text to GUI Label Script? 1 Answer
The next problem with gui. 1 Answer
changing font + size of text 1 Answer