I want to make a menu inside the game. So if you pres escape a window appears with buttons. When the window appears the mouselook script from the First Player Controller must be disabled. I found and used this script, what seems to be oke. but I get a error when i press escape
NullReferenceException: Object reference not set to an instance of an object Gui.window.Update () (atAssets\script\Gui_window.js:25)
var SkinWindow: GUIStyle;
var SkinTitle : GUIStyle;
var SkinButton: GUIStyle;
private var doWindow0 : boolean= false;
private var gameobj : GameObject;
private var mouseL : MouseLook;
private var cam : GameObject;
private var mouseL2 : MouseLook;
private var windowRect0= Rect(50,50,300,300);
function Awake()
{
gameobj =GameObject.Find("First Person Controller");
mouseL = gameobj.GetComponent(MouseLook);
cam = gameobj.Find("First Person Controller/Main Camera");
mouseL2 = cam.GetComponent(MouseLook);
}
function Update ()
{
if(Input.GetKeyDown(KeyCode.Escape))
{
doWindow0= !doWindow0;
mouseL.enabled=!mouseL.enabled;
mouseL2.enabled=!mouseL2.enabled;
}
}
function OnGUI ()
{
if(doWindow0)
GUI.Window(0,Rect(300,10,500,500),StartWindow0,"CONTROLS",SkinWindow);
}
/*GUIWindow content*/
function StartWindow0 (windowID : int)
{
GUI.Label (Rect (50,50,350,100), "OM ROND TE LOPEN, GEBRUIK PIJLTOETSEN",SkinTitle);
doWindow0=GUI.Toggle(Rect(400,400,76,76),doWindow0,"EXIT",SkinButton);
GUI.DragWindow(Rect(0,0,10000,10000));
}
I got the standard First person controller from the standard assets
please help!