如何使用Scroll Rect安排Desain游戏对象或UI使其可滚动? Unity C# [英] How To Arrange a Desain Gameobject or UI to become Scrollable using Scroll Rect ? Unity C#

查看:111
本文介绍了如何使用Scroll Rect安排Desain游戏对象或UI使其可滚动? Unity C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我.

如何排列游戏对象或UI使其变得类似于屏幕截图,并使其可以使用scroll rect滚动?

How to arrange gameobject or UI to become like the screenshot and make it scrollable using scroll rect ?

用户界面的排列方式必须类似于屏幕截图.

The UI must be arrange like screenshot.

有一个黄色的边框包含UI,它必须是可雕刻的. 然后有一个青色边框,其中包含5个或更多插槽项目,并且也可以滚动.它可以自动或手动生成. 然后是包含3个按钮UI的洋红色边框.按钮1,按钮2和按钮3.每个按钮的大小都不同.

There is a border yellow contain the UI and it must be scroollable. and then there is a cyan border contain 5 Slot item or more and scrollable too. it can be generate automatically or manual. And then there is a magenta border contain 3 button UI. Button 1, button 2, and button 3. Each button have different size.

为什么它必须是可滚动的?因为青色边框包含和洋红色边框包含可以不止一个.因此,如果无法滚动,则该对象将不足以显示在黄色边框中.

Why it must be scrollable ? Because The Cyan border Contain and the Magenta border contain can be more than one. So if it not scrollable then the object wouldn't enough to show in the yellow border box.

我已经尝试做1天了,但是我做不完.

I have try to make it for 1 day and i can't finish it.

请帮助我完成它以及如何逐步进行.

Please help me how to finish it and how to make it step by step.

如果您有任何问题,请发表评论.

if you have any question just comment it.

非常感谢

推荐答案

我自己找到了答案.

这就是它的工作方式.

  1. 创建游戏对象名称面板过程 在Panelprocess中添加组件:图像,遮罩和滚动矩形

  1. Create Gameobject Name Panelprocess In the Panelprocess add component : image, mask and scroll rect

创建子GameObject Panelproceess名称ListProcess

Create child Gameobject Panelproceess Name ListProcess

在ListProcess中添加组件:Grid Layout Group并包含大小调整器 在网格布局组"组件中,按如下所示设置值:

In the ListProcess add component : Grid Layout Group and contain size fitter at Grid Layout Group component set the value like below :

像元大小:x(285)y(65) 约束:固定列数 约束数:1

cell size : x ( 285 ) y ( 65 ) constraint : fixed column count constraint count : 1

在包含尺寸装配器"中,设置如下值:

at Contain size fitter set the value like below :

水平配合:首选尺寸 垂直适合:预设尺寸

horizontal fit : preffered size vertical fit : preffered size

创建子Gameobject ListProcess名称Item1(UI图像),Button1(UI图像),Item2(UI图像),Button2(UI图像)

Create child Gameobject ListProcess Name Item1 (UI Image), Button1 (UI Image), Item2 (UI Image), Button2 (UI Image)

创建子游戏对象Item1名称Slot1(UI图像),Slot2(UI图像),Slot3(UI图像),Slot4(UI图像),Slot5(UI图像)

Create child Gameobject Item1 Name Slot1 (UI Image), Slot2 (UI Image), Slot3 (UI Image), Slot4 (UI Image), Slot5 (UI Image)

注意:根据屏幕快照安排插槽的位置和大小 对Item2也执行步骤4

Note : Arrange the position and size of slot according to the screenshot Do step 4 for Item2 too

创建子游戏对象BUtton1名称Btn1,Btn2,Btn3 注意:安排每个btn1,btn2,btn3的位置和大小 屏幕截图. 对Button2也执行步骤5

Create child Gameobject BUtton1 Name Btn1, Btn2, Btn3 Note : Arrange the position and size of each btn1, btn2, btn3 accroding to the screenshot. Do step 5 for Button2 too

返回游戏对象Panelprocess 在Panelprocess组件上: 滚动Rect(如下所示进行设置):

Back to gameobject Panelprocess at Panelprocess component : Scroll Rect (set the setting like below) :

content:(将ListProcess游戏对象拖到content上) 水平:未选中 垂直:已检查 运动类型:弹性

content : (Drag the ListProcess gameobject to content) Horizontal : unchecked vertical : checked MOvement Type : Elastic

现在播放. 现在,网格布局组"包含一个具有不同大小且可滚动的对象.

Now Play it. The Grid Layout Group now contain and object with a different size and scrollable.

完成

这篇关于如何使用Scroll Rect安排Desain游戏对象或UI使其可滚动? Unity C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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