UI面板的固定高度具有缩放宽度[Unity]

发布于 2025-01-21 21:18:19 字数 450 浏览 1 评论 0原文

我必须在UI的底部制作2个面板。无论游戏窗口尺寸如何,左下面板都需要保持固定的平方尺寸。右下面板需要保持固定高度,但要扩展宽度,以填充左下面板和游戏窗口右侧的所有空间。

此绿色面板应保持一个恒定的正方形,而蓝色面板则需要扩大其宽度,而不是在调整游戏窗口时的高度。

我尝试将它们分成两个不同的画布,并使用水平布局组,但我无法理解我要寻找的东西。我获得的最接近的是一个没有扩展(常数像素大小)的单个画布,以及一个水平布局组,其蓝色面板的最大宽度为我的显示分辨率。当游戏窗口缩小时,这会导致蓝色面板刚刚脱离屏幕,但我需要它以完全适合窗口。

I have to make 2 panels on the bottom of the UI. The bottom left panel needs to stay at a fixed square size regardless of the game window size. The bottom right panel needs to keep a fixed height but expand the width to fill all the space in between the bottom left panel and right of the game window.

enter image description here

This green panel should remain a constant sized square, while the blue panel needs to expand its width but not its height when the game window is resized.

I've tried separating them into two different canvas', and using a horizontal layout group, but I can't get what I'm looking for. The closest I've gotten is with a single canvas that doesn't scale (constant pixel size), and a horizontal layout group that has the blue panel at a maximum width for my display resolution. This leads to the blue panel just going off screen when the game window is downsized, but I need it to fit exactly to the window.

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

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

发布评论

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

评论(2

小梨窩很甜 2025-01-28 21:18:19

绿色:

蓝色:

“

canvas(通知匹配设置为1):

我希望它能给出您正在寻找的结果

Green:

Green

Blue:

Blue

Canvas (notice Match set to 1):

Canvas

I hope it gives the result you were looking for

凉宸 2025-01-28 21:18:19

除了@slowikowskiarkadiusz的答案中,我能够通过遵循所有这些步骤来获得我的预期结果,除了我为Canvas Scaleer使用了常量的像素大小。蓝色面板的锚点使其仍然可以扩展宽度,但是恒定像素尺寸使高度保持恒定。

Adding to @slowikowskiarkadiusz answer, I was able to get my intended result by following all of these steps, except I used Constant Pixel Size for the canvas scaler. The anchor points of the blue panel allow it to still expand width, but constant pixel size kept the height constant.

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