I have a problem using this code :
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class MouseController : MonoBehaviour {
public GameObject Crosshair;
private RaycastHit rayHit;
public Text HitsTXT;
public Text MissesTXT;
public Text ShotsFiredTXT;
public int hits;
public int Misses;
public int ShotsFired;
// Use this for initialization
void Start () {
hits = 0;
HitsTXT.text = "Hits : " + hits.ToString ();
Misses = 0;
MissesTXT.text = "Misses : " + Misses.ToString ();
ShotsFired = 0;
ShotsFiredTXT.text = "Shots Fired : " + ShotsFired.ToString ();
}
it gives the following error :
NullReferenceException: Object reference not set to an instance of an object
MouseController.Start () (at Assets/MouseController.cs:20)
The weird part is that the game pauses but it does change the text but i dont want the error/crash
How do i fix this?
↧