GUIText已弃用,所以我应该用它代替它? [英] GUIText is deprecated, so what should I use instead of it?
问题描述
我正在使用Unity 2017.2.0f3,当我使用 GUIText
时,它显示此组件是旧版UI系统的一部分,并将在以后的版本中删除."那么我应该使用的最佳替代方法是什么?
I'm using Unity 2017.2.0f3 and when I use GUIText
, it is showing "this component is part of the legacy UI system and will be removed in a future release." So what is the best alternative I should use?
推荐答案
Text
组件替换了它.它是名为uGUI的新UI系统的一部分.
The Text
component replaced it. It's part of the new UI system called uGUI.
转到GameObject ---> UI->文本和Unity将创建一个以GameObject作为子代的Canvas.该子GameObject将具有Text
组件.您可以在此处了解更多信息.
Go to GameObject ---> UI ---> Text and Unity will create a Canvas with a GameObject as a child. That child GameObject will have a Text
component. You can learn more about the new UI system here.
如何通过代码对其进行修改的示例:
Example of how to modify it from code:
public Text myText;
void Start()
{
myText.text = "This is my text";
}
这篇关于GUIText已弃用,所以我应该用它代替它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!