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 ---> Text 和 Unity 将创建一个 Canvas,其中一个 GameObject 作为子项.该子 GameObject 将有一个 Text
组件.您可以在此处了解有关新 UI 系统的更多信息.
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屋!