This question was
closed Dec 27, 2015 at 01:20 PM by
Ali-hatem for the following reason:
The question is answered, right answer was accepted
Question by
Ali-hatem · Dec 27, 2015 at 01:06 PM ·
unity 4.6object-reference-error
NullReferenceException: Object reference not set to an instance of an object ( UI.text ) ?
Hi : i want to change a ui text from scripting but i get this error i mentioned in the question and this is my script :
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class MyScript : MonoBehaviour
{
public Text livscoretext;
void Start ()
{
livscoretext = GetComponent<Text>();
livscoretext.text = "score" ;
}
}
Comment
Answer by Ali-hatem · Dec 27, 2015 at 01:19 PM
i solved it one minute after posting my question !
// i just removed
livscoretext = GetComponent<Text>();
//and used only
livscoretext .text = "score";
Follow this Question
Related Questions
Game objects do not appear on random iOS phones with random OS versions 0 Answers
How to Drow 2d Random Maze with single path in unity. 0 Answers
UI Prev button 0 Answers
What is the command to stop the Update function ingame? (c#) 1 Answer
WHY !! CountDown not Working inside the IF Conndition !!! 2 Answers