Unity 3D:将UI元素添加到游戏画布

本文介绍了如何在Unity 3D中向游戏添加UI元素,特别是文本标签。首先,Unity自动在场景中创建Canvas。接着,通过Hierarchy菜单添加Text标签,可以设置文本颜色、大小和字体。然后,通过调整标签大小和位置,使其在画布中清晰可见。最后,文章提及将探讨如何实时更新文本UI以显示游戏进度信息。
摘要由CSDN通过智能技术生成

So now that we have a good idea of how the Canvas works, let's try adding our own elements into the game. We'll start with a very simple label. A label is simply static text that you use on the User Interface. Let's have our label say Use the arrow keys to move.

因此,既然我们对Canvas的工作原理有了一个很好的了解,让我们尝试将自己的元素添加到游戏中。 我们将从一个非常简单的标签开始。 标签只是您在用户界面上使用的静态文本。 让我们让标签说“ 使用箭头键移动”

First off, to add any UI element, we now know that we need a Canvas first. However, Unity saves us the trouble of inserting a new Canvas into the scene, by doing it automatically when you create a UI element in a scene that doesn't already have a Canvas.

首先,要添加任何UI元素,我们现在知道首先需要Canvas 。 但是,当您在尚无Canvas的场景中创建UI元素时,通过自动执行操作,Unity避免了将新Canvas插入场景的麻烦。

To add a label into the scene, right click in the Hierarchy and select UI Elements → Text.

要将标签添加到场景中,请在“ 层次结构”中单击鼠标右键,然后选择“ UI元素”→“文本”

Adding UI Elements to canvas Unity 3D

As soon as you click on Text, you'll notice a new addition in your Hierarchy view.

一旦单击“ 文本” ,您就会在“ 层次结构”视图中注意到一个新的添加。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值