根据屏幕尺寸缩放 UI 按钮和图像
我正在开发一款统一游戏,我希望能够缩放按钮和 UI 元素以适应不同的屏幕尺寸。请问我该怎么办?我尝试过根据屏幕尺寸进行缩放,但它似乎对我没有帮助。有一个我可以使用的脚本吗?
I ma developing a game for unity and i want to be able to scale my buttons and UI elements to fit different screen sizes. Please how can i go about this? I have tried scale with screen size and it doesn't seem to help me. Is there a script i can use for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将需要使用画布缩放器
您只需将此对象附加到画布上,作为 UI 元素的父级,它就会相应地缩放它们。
您还需要确保您的 UI 元素是 正确锚定,以便它们用正确的锚点拉伸 观点。
You will want to use a canvas scaler for this.
You simply attach this object to your canvas parenting your UI elements and it will scale them acordingly.
You will also want to make sure your UI elements are anchored correctly so that they stretch with their correct anchor point.