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
Post a Comment