Problems with GUI texture

Hello,
In the game, pressing “p” activates Paused, which sets time.timeScale to 0 (pauses the game) and it also should draw a GUI textures but that’s the problem, it doesn’t work.

Here is the error that is given

Here’s our code:

#pragma strict

private var pauseGame : boolean = false;
var aTexture : Texture;

function Pause () {
	{
		Time.timeScale = 0;
		pauseGame = true;
		
	}
	
}

function Start (){
	Time.timeScale = 1;
}

function Update () {
	if (Input.GetKeyDown("p"))

	{
		pauseGame = !pauseGame;
	}

	if (pauseGame == true){
		Pause();
		GUI.DrawTexture(Rect(0,0,Screen.width,Screen.height), aTexture, ScaleMode.ScaleToFit, true, 10.0f);
	}

	 if (pauseGame == false)
		
	{
		pauseGame = false;
	}

}

GUI.DrawTexture just works on OnGUI()

#pragma strict

private var pauseGame : boolean = false;
var aTexture : Texture;

function Start (){
   Time.timeScale = 1;
}

function Update () {
   if (Input.GetKeyDown("p")) {
      Pause ();
   }

function OnGUI() {
if(pauseGame){
       GUI.DrawTexture(Rect(0,0,Screen.width,Screen.height), aTexture, ScaleMode.ScaleToFit, true, 10.0f);
}
}

function Pause () {
   pauseGame = !pauseGame;
   if(pauseGame) { Time.timeScale = 0; }
    else { Time.timeScale = 1;}
}

maybe there is a syntax error, myself coding in c#

1 Like

Ohhh, thank you very much. I wasn’t paying enough attention in the docs :confused: