Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

i cant put text into a ui text thru a c# script

$
0
0
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?

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>