Hello! I cant slove 1 error with 3d text. I see many YouTube video and for uploaders of video its works, but with my projects its dont work… Here my Update script. i just call that script from another to update text value .
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class PointTracker : MonoBehaviour {
GameObject PointNum;
Text TextNum;
int CurrentPoints = 0;
// Use this for initialization
void Start () {
PointNum = GameObject.Find("PointNum");
TextNum = PointNum.GetComponent<Text>();
UpdatePoints(CurrentPoints);
}
// Update is called once per frame
void Update () {
}
public void UpdatePoints(int addNum)
{
CurrentPoints = CurrentPoints + addNum;
TextNum.text = "" + CurrentPoints;
}
}
and its string
TextNum.text = "" + CurrentPoints;
Call that error:
NullReferenceException: Object reference not set to an instance of an object
PointTracker.UpdatePoints (Int32 addNum) (at Assets/Scripts/PointTracker.cs:27)
Please help me and say what i am doing wrong…
Thanks.