如何在Unity 2021.3.3f1中创建按钮?

发布于 2025-01-31 12:25:06 字数 292 浏览 3 评论 0原文

我正在遵守我在Udemy上找到的团结课程。在课程的第一部分中,他教您制作一个不需要编码的简单迷宫游戏。在一个部分中,他使用将控制游戏的按钮,因此我们不必使用代码。他正在使用Unity 2021.1。 (我不完全记得)。在他的视频中,他右键单击层次结构 - > ui - >按钮(在我的版本中,您必须转到遗产 - >按钮),然后在他的屏幕左下角出现一个按钮,即使您移动相机,它也会留在那里屏幕的一部分,像2D精灵一样移动,就像一个2D矩形一样,它可以更改文本,而不是留在屏幕上的底部。另外,主相机看不到它。我了解该帖子很难阅读,但所有的帮助都非常感谢!

I am tying to follow this Unity course I found on Udemy. In the first part of the course, he teaches you to make a simple maze game that requires no coding. In one section he uses buttons that will control the game so we don't have to use code. He is using Unity 2021.1.? (I don't remember fully). In his video, he right clicks in the hierarchy -> ui -> button (in my version you have to go to legacy -> button instead) then a button appears in the bottom left corner of his screen which stays there even if you move the camera whereas in mine it just generates a 2d button in a random part of the screen and moves like a 2d sprite as it like a 2d rectangle which can change text and not a bottom that stays on my screen. Also the main camera can't see it. I understand the post is hard to read but all help is appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浸婚纱 2025-02-07 12:25:06

检查您的画布是否是屏幕空间覆盖层,之后,您需要选择按钮并根据主相机调整按钮位置。

将锚固预设更改为右下,然后调整X& y坐标相应地将您的按钮放在屏幕的右下角。

这些设置对我来说很好(x = 80& y = 15)。

Check if your canvas is Screen Space Overlay, after that, you need to select your button and adjust your buttons position according to main camera.

Change your anchor presets to bottom right, then Adjust X & Y coordinates accordingly to place your button in bottom right corner of screen.

These settings worked fine for me (X=80 & Y=15) .

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文