面板
面板(panel)控件,在屏幕中也是一个不可缺少的元素,是一个看不见的控件。
它作为一种容器,可以将内容分组,可以为一些控件归为一组!你可以将它理解为收纳箱,size 可以定义收纳箱的容量大小、配合其他属性使用。
集合面板与普通面板特效基本一致,集合面板允许使用集合属性,为了区分这两个控件,本文章中主要内容为面板控件。
虽然控件看不见,但可以占用一定空间:RP/ui/start_screen.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"stack": { "type": "stack_panel", "size": [100,100], "controls": [ { "panel": { "type": "panel", "size": [10,10] } }, { "label": { "type": "label", "text": "hello world", "anchor_from": "top_right", "anchor_to": "top_right" } } ]}
面板,可以影响所有子控件的一些相对属性(不是改变子控件的属性,其他类型的控件也是如此),
例如改变面板控件的
面板相当于HTML的
例如:
RP/ui/start_screen.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"panel": { "type": "panel", "size": [ 100, 100 ], "controls": [ { "label": { "type": "label", "text": "hello world", "anchor_from": "top_right", "anchor_to": "top_right" } }, { "board": { "type": "image", "texture": "textures/ui/focus_border_white", "nineslice_size": 1, "size": [ "100%", "100%" ] } } ]}

面板可以改变 "label" 控件的锚点定位,因为锚点是基于父控件定位的。
对于面板控件,可以使用全局属性,没有独有的特殊属性。
代码示例
模板
1
2
3
4
5
"panel":{ "type": "panel", "size": [], "controls": []}
RP/ui/start_screen.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"panel": { "type": "panel", "size": [ 100, 100 ], "controls": [ { "label": { "type": "label", "text": "hello world", "anchor_from": "top_right", "anchor_to": "top_right" } }, { "board": { "type": "image", "texture": "textures/ui/focus_border_white", "nineslice_size": 1, "size": [ "100%", "100%" ] } } ]}
如果有什么问题可以在视频评论区提问哦 (~ ̄▽ ̄)~