Unity: text type problem in ScoreManager script

I did UI Canvas, and then plugged in UI Text, called it ScoreText. I also have a ScoreManagerscript to reset the score and enter text into it.

the code

public class ScoreManager : MonoBehaviour {
    public static int score;
    Text text;
    void Awake () {
        text = GetComponent <Text> ();
        score = 0;
    }
    void Update () {
        text.text = "Score: " + score;
        Debug.Log (score);
    }
}

The code is attached to ScoreText. He works in an official unity survival manual and also worked on my project.

But the problem is that it is not recognized. "Type or namespace not found." Text text Text

He worked at unity4. My current project is in unity5. The counter works fine at debug.log. Now I want to set the evaluation text.

+4
source share
1 answer

Add

using UnityEngine.UI;

, .

, Unity Game Engine - Unity3d, Unity:)

+2

All Articles