将UI按钮放在视口/屏幕的左下角? [英] Position a UI button on bottom left of the viewport/screen?

查看:108
本文介绍了将UI按钮放在视口/屏幕的左下角?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何放置UI按钮(新UI),使其始终位于屏幕/视口的左下角?我的想法是用这样的代码来做到这一点:

How do I place a UI Button (the new UI) so that it is always at the bottom-left on the screen/viewport? My idea was to do it in code like this:

void Awake () {
  fireButton.transform.position = new Vector3(Screen.width - 50, Screen.height - 50, 0);
}

它根本不起作用.我怎样才能最好地做到这一点?

It is not working at all. How can I best do this?

推荐答案

与其在代码中进行操作,请单击场景或层次结构中的UIButton,然后进入检查器,然后在转换组件的左上方一个正方形,单击它,按住shift和alt,然后单击左下角"正方形,将其锁定到屏幕的那一侧.

Instead of doing it in code, click on the UIButton in the scene or hierarchy then go into the inspector and in the top left of the transform component you will see a square, click it, hold shift and alt and then click the 'Bottom Left' square to latch it to that side of the screen.

这篇关于将UI按钮放在视口/屏幕的左下角?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆