- Home /
Question by
Roulette36 · Jun 08, 2015 at 07:27 AM ·
javascripterrorsliderguitext
Null reference exception error when using a slider
Hi everyone!
I'm trying to create a slider and a text, which shows the slider's current value when it's being assigned using this code:
#pragma strict
var text: GameObject;
private var textContent: UI.Text;
function Awake()
{
textContent = text.GetComponent.<UI.Text>();
Debug.Log(textContent);
}
function Slider(info: float)
{
textContent.text = "Current value: "+info;
Debug.Log(textContent);
}
The thing is that it tells me this error: "NullReferenceException: Object Reference not set to an Instance of an Object" but I've set it in the inspector.
EDIT: I've deleted the 14th line and the console told me first that the object reference is the object I've assigned in the inspector, but when I use the slider it told me that the object reference is null.
Comment
Your answer
Follow this Question
Related Questions
How do I change the text of a gui image text 1 Answer
Error BCE0044 plz help 0 Answers
How to use if statement with var? 3 Answers
Animation Crossfade won't play but Animation Play does 1 Answer