NullReferenceException: Object reference not set to an instance of an object
CursorControl.Update () (at Assets/Scripts/CursorControl.cs:42)
I have been looking at this for the past few days and I can’t seem to find out whats wrong. I don’t even know if its this script that’s the problem at this point but I looked at the others and they seem ok too.
using UnityEngine;
using System.Collections;
public class CursorControl : MonoBehaviour {
private GameObject multiplayerManager;
private MultiplayerScript multiScript;
private GameObject gameManager;
private CommunicationWindow commScript;
private ScoreTable scoreScript;
private GameSettings settingsScript;
void Start(){
if(networkView.isMine == true){
multiplayerManager = GameObject.Find("MultiplayerManager");
multiScript = multiplayerManager.GetComponent<MultiplayerScript>();
gameManager = GameObject.Find("GameManager");
commScript = gameManager.GetComponent<CommunicationWindow>();
scoreScript = gameManager.GetComponent<ScoreTable>();
settingsScript = gameManager.GetComponent<GameSettings>();
}
else{
enabled = false;
}
}
void Update(){
if(multiScript.showDisconnectWindow == false &&
commScript.unlockCursor == false &&
scoreScript.blueTeamHasWon == false &&
scoreScript.redTeamHasWon == false &&
settingsScript.showSettings == false){
Screen.lockCursor = true;
}
if(multiScript.showDisconnectWindow == true ||
commScript.unlockCursor == true ||
scoreScript.blueTeamHasWon == true ||
scoreScript.redTeamHasWon == true ||
settingsScript.showSettings == true){
Screen.lockCursor = false;
}
}
}