- Home /
Why my rect not working
My rect don't print anything. Why?
using UnityEngine;
using System.Collections;
public class pause : MonoBehaviour {
public GUISkin Myskin;
private Rect windowRect;
private Rect optionRect;
private bool pauseMenu = false;
private bool optionMenu = false;
// Use this for initialization
void Start () {
windowRect = new Rect(Screen.width / 2 - 100, Screen.height / 2 - 100, 200, 200);
optionRect = new Rect(Screen.width / 2 - 100, Screen.height / 2 - 100, 200, 200);
}
// Update is called once per frame
void Update () {
if (Input.GetKey(KeyCode.P)) {
pauseMenu=true;
}
if (pauseMenu) {
Time.timeScale = 0;
} else {
Time.timeScale = 1;
}
}
private void OnGui() {
if (pauseMenu) {
windowRect = GUI.Window(0, windowRect, windowFunc, "Pause");
}
if (optionMenu) {
optionRect = GUI.Window(0, optionRect, optionFunc, "Options");
}
}
private void windowFunc( int id) {
if (GUILayout.Button ("Resume")) {
pauseMenu = false;
}
if (GUILayout.Button("Options")) {
optionMenu = true;
}
if (GUILayout.Button ("Save")) {
}
if (GUILayout.Button ("Quit")) {
Application.LoadLevel("window");
}
}
private void optionFunc( int id ) {
if (GUILayout.Button ("Back")) {
optionMenu = false;
}
}
}
Comment
Answer by whydoidoit · Sep 06, 2012 at 01:07 PM
The routine is called OnGUI not OnGui - so your code isn't being called.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
need help with script 1 Answer
Simple Code Not Working 4 Answers
Can't get bullet to spawn and move 1 Answer
Any idea why collision detection not working? [Video] 0 Answers