0
我正在尝试创建一个描述运行时对象的文本,但创建了GUIText对象,但它不可见。有任何想法吗 ?Unity3d:在运行时创建GUIText文件
这里是我的代码:
void enemydescriptionInit(GameObject text, string desc){
text.transform.parent = enemyCar1.car.transform;
enemyCar1.car.transform.position = enemyCar1.startPosiotion;
text.gameObject.GetComponent<GUIText>().font = new Font ("Arial");
text.gameObject.GetComponent<GUIText>().text = desc;
text.gameObject.GetComponent<GUIText>().fontSize = 40;
text.gameObject.GetComponent<GUIText>().fontStyle = FontStyle.BoldAndItalic;
text.gameObject.GetComponent<GUIText>().color = Color.blue;
text.gameObject.name = "Desc";
}
void Start() {
player = GameObject.Find ("Player");
text = new GameObject();
text.AddComponent<GUIText>();
}
void Update(){
enemydescriptionInit (text, "HELLO");
}
GUIText是传统组件。尝试使用[新UI](http://docs.unity3d.com/Manual/UIOverview.html)(从版本4.6开始)。处理起来要容易得多。 –
我同意Marius Junak - 使用Unity 5 - 它拥有免费的所有Pro功能,并且新UI更好,更好。 – JinJi
这是我的第一个团结项目,我使用的是Unity 5,你们使用“新UI”是什么意思? – Anima