- Home /
Null reference exception?
I have a scenario in which when an object passes through colliders acting as triggers, a timer pops up on the screen then leaves the screen using an exit script. It works fine for the first trigger, but when the object reaches the second trigger everything goes whacko. The timer continues to flash onto the screen even though it should be inactive. I get a repeated error: "null reference exception, Object Reference not set to instance of an object in TimerUpdate()" for this line of my timer script (C#):
text.text = "Potential Eclipse:" + Mathf.Round(timeLeft);
(the timer is an eclipse countdown). I'm new to Unity, what does this mean and how can I fix it?
text.text
your text component doesn't exist. or isn't found. and then doing .text on it triggers the null reference. Please learn C# before attempting unity;
Answer by LocalNoob · Aug 02, 2017 at 06:55 PM
Your text reference is probably a null, do you destroy your text element?
Suddenly I'm now not getting any errors, but the flashing of the text on the screen is still occurs twice and then stops... very confused at the inconsistency in my issue here.
Your answer
Follow this Question
Related Questions
NullReferenceException 2 Answers
Javascript Basic Lap Timer with GUI 1 Answer
Why do I get a null reference with this timer? 2 Answers
Specific points in audio should trigger events 0 Answers
How to set timer for WWW helper? 1 Answer