unity5 Text

unity5中,添加Text对象:

在其它对象的脚本中如果想引用此Text,则应定义:

public UnityEngine.UI.Text myText;

然后把对象拖到变量上即可。

注:

1,需要注意的是,如果写成:

public GUIText myText;

则把对象拖到变量上时是不认的。GUIText是旧版unity中用的类型。

2,UnityEngine.UI是Text的命名空间,必须写成UnityEngine.UI.Text,而不能直接写成Text,见unity Scripting API文档:

Text

Namespace: UnityEngine.UI / Inherits from: UI.MaskableGraphic

Implements interfaces: ICanvasElement, ILayoutElement, IMaskable”

原文地址:https://www.cnblogs.com/wantnon/p/4357690.html