- Home /
C# pausing the game during GUI keypad
Hello, I got this keypad script, which I wrote myself, and I was wondering if its possible to pause the movement of the camera while the GUI is up, and if I click on the GUI "Ok" button, the movement comes back as right now when Im trying to click the GUI buttons on my keypad. If you have played Splinter Cell Chaos Theory, like those keypads.
Keypad Code:
public class Keypad : MonoBehaviour
{
public string password = "1234";
private string pwd = "";
private bool Frodo;
public AudioClip Ok;
public GameObject objectToMove;
// Use this for initialization
void Start ()
{
Frodo = false;
}
void Update()
{
if (Input.anyKeyDown) { return; }
}
void OnTriggerEnter()
{
Frodo = true;
}
void OnGUI()
{
GUI.color = Color.blue;
if (Frodo == true)
{
GUI.Box(new Rect(275, 50, 350, 250), "");//bakgrundsfält till knapparna
pwd = GUI.PasswordField(new Rect(325, 60, 200, 50), pwd, "*"[0], 4);//4 siffrigt lösenord fält.
if(GUI.Button(new Rect(350, 125, 50, 50), "1"))
{
pwd += "1";
audio.Play();
}
if(GUI.Button(new Rect(400, 125, 50, 50), "2"))
{
pwd += "2";
audio.Play();
}
if(GUI.Button(new Rect(450, 125, 50, 50), "3"))
{
pwd += "3";
audio.Play();
}
if(GUI.Button(new Rect(350, 175, 50, 50), "4"))
{
pwd += "4";
audio.Play();
}
if(GUI.Button(new Rect(400, 175, 50, 50), "5"))
{
pwd += "5";
audio.Play();
}
if(GUI.Button(new Rect(450, 175, 50, 50), "6"))
{
pwd += "6";
audio.Play();
}
if(GUI.Button(new Rect(350, 225, 50, 50), "7"))
{
pwd += "7";
audio.Play();
}
if(GUI.Button(new Rect(400, 225, 50, 50), "8"))
{
pwd += "8";
audio.Play();
}
if(GUI.Button(new Rect(450, 225, 50, 50), "9"))
{
pwd += "9";
audio.Play();
}
if(GUI.Button(new Rect(500, 125, 65, 45), "Clear"))//rensar passwordfältet
{
audio.Play();
pwd = "";
}
if(GUI.Button(new Rect(500, 190, 85, 85), "Ok"))//Ok knapp som man klickar på efter koden
{
audio.Play();
if (pwd == password)
{
audio.PlayOneShot(Ok);
objectToMove.transform.position = new Vector3(-75, 6, -18);
}
}
}
}
void OnTriggerExit()
{
Frodo = false;
}
}
Thanks in advance.
Is the movement of the camera controlled by something like $$anonymous$$ouseLook? If so, get references to the $$anonymous$$ouseLook component and set them to disabled while GUI is up.
Like Getcomponent > disable that script on Trigger enter > when click Ok GUI button > enable that script
But I've called my mouse script here Smooth$$anonymous$$ouseLook mouselook = GetComponent(); and how do I disable it?
Answer by getyour411 · Mar 29, 2014 at 01:03 AM
().enabled and ().disabled
See the docs and plenty of other resources for more info
Your answer
Follow this Question
Related Questions
C# GUI keypad 2 Answers
GUI.PasswordField "•" makes "?" 1 Answer
Close my GUI button by repressing the same Hot-key. 3 Answers
help with errors 2 Answers
How to toggle the color of a button? 1 Answer