C#
When my player is instantiated over the network, one of the variables on my pause menu script seems to not be assigned. I do not want to use my pause menu canvas as a prefab, but if I have to, I will. Assigning the canvas in the player prefab doesn't work either.
Picture of what I mean when I say missing variable - http://prntscr.com/4tqgf0
Pause Menu Script ( C# ) -
using UnityEngine;
using System.Collections;
public class PauseGame : MonoBehaviour {
private bool pauseGame = false;
public GameObject PauseMenuCanvas;
void Update () {
if (Input.GetKeyDown (KeyCode.Escape)) {
pauseGame = !pauseGame;
if(pauseGame == true) {
pauseGame = true;
PauseMenuCanvas.SetActive(true);
GameObject.Find("Player").GetComponent().enabled = false;
GameObject.Find("Main Camera").GetComponent().enabled = false;
}
if(pauseGame == false) {
pauseGame = false;
PauseMenuCanvas.SetActive(false);
GameObject.Find("Player").GetComponent().enabled = true;
GameObject.Find("Main Camera").GetComponent().enabled = true;
}
}
}
}
↧