c# - Unity: Text type issue in a ScoreManager script -


i've done ui canvas , attached ui text, named scoretext. have scoremanager script resetting score , writing text it.

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 attached scoretext. working in official unity's survival shooter tutorial , worked project well.

but problem text text not recognized. "the type or namespace text not found."

it worked in unity4. current project in unity5. counting works fine in debug.log. want set score text.

add

using unityengine.ui; 

at top of code in order import namespace.

side note, tag unity game engine unity3d, not unity :)


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -