我的世界基岩版 UI 文档

面板

面板(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"
}
}
]
}

面板,可以影响所有子控件的一些相对属性(不是改变子控件的属性,其他类型的控件也是如此), 例如改变面板控件的layer(相对层级),就会影响到子控件的总层级。 (本控件的总层级=父控件的相对层级+本控件的相对层级)

面板相当于HTML的<div>

例如:

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%" ]
}
}
]
}
好了,文档就讲完面板控件了。
如果有什么问题可以在视频评论区提问哦 (~ ̄▽ ̄)~
版权声明- 除非另有说明,否则文档内容均采用CC BY-NC-SA 4.0许可协议
- 此网站与 Mojang Studios 以及微软无任何从属关系
- 转载需要作者同意,并且标明内容来自于本网站
 导航&目录