Position a UI button on bottom left of the viewpor

2019-03-02 09:12发布

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?

标签: unity3d
1条回答
手持菜刀,她持情操
2楼-- · 2019-03-02 09:39

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.

查看更多
登录 后发表回答