- Home /
Unable to reference a component.
I've tried to use an exact script from a tutorial by uniy(link: http://unity3d.com/learn/tutorials/projects/survival-shooter/scoring-points) the code :
static var score : int;
private var text : Text;
function Awake () {
text = GetComponent (Text);
score = 0;
}
function Update () {
text.text = "Score: " + score;
}
For what i know everything was correct but it is giving me this error : Assets/Scripts/ScoreManager.js(3,20): BCE0018: The name 'Text' does not denote a valid type ('not found'). Did you mean 'UnityEngine.UI.Text'?
please help me. Thank you in advance
Where it says GetComponent (Text);
change it to GetComponent ("Text");
For all the other instances of GetComponent, you will need speech marks there too
Answer by Qasem2014 · Dec 28, 2014 at 01:19 PM
do you use this code in your script ?
import UnityEngine.UI;
@Qasem2014 where did you put the import UnityEngine.UI; in your code? When I added it into the same code @eshwar was using, it gave me a new error. BCE0044: expecting EOF, found 'import'.
Your answer
Follow this Question
Related Questions
Best method for updating children of instantiated buttons? 0 Answers
New UI: Text scale/drawing problem 1 Answer
Unity 4.6 UI Text is really small when I build the game? 1 Answer
What's your equivalent of old GUIStyle ? 0 Answers
Try to reproduce this Text UI element "bug" if you are developing for IOS 0 Answers