Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

MarginContainer

繼承: Container < Control < CanvasItem < Node < Object

被繼承: EditorDock

在子控制項周圍保留邊距的容器。

說明

MarginContainer 會為子控制項的各條邊加上可調整的邊距。是在所有子項周圍新增邊距,而不是在它們各自周圍新增邊距。要控制 MarginContainer 的邊距,請使用下列 margin_* 主題屬性。

注意:邊距大小是主題覆蓋項,而不是普通的屬性。如果想要通過程式碼更改,應使用以下範例:

# 這段程式碼範例要求目前腳本擴充的是 MarginContainer。
var margin_value = 100
add_theme_constant_override("margin_top", margin_value)
add_theme_constant_override("margin_left", margin_value)
add_theme_constant_override("margin_bottom", margin_value)
add_theme_constant_override("margin_right", margin_value)

教學

主題屬性

int

margin_bottom

0

int

margin_left

0

int

margin_right

0

int

margin_top

0


主題屬性說明

int margin_bottom = 0 🔗

Offsets towards the inside direct children of the container by this amount of pixels from the bottom.


int margin_left = 0 🔗

Offsets towards the inside direct children of the container by this amount of pixels from the left.


int margin_right = 0 🔗

Offsets towards the inside direct children of the container by this amount of pixels from the right.


int margin_top = 0 🔗

Offsets towards the inside direct children of the container by this amount of pixels from the top.