GUML supports the following variables:
- Alias variable
- Global variable
- Local variable
Alias for ui node. So that the corresponding ui node can be referenced in guml file or corresponding controller.
Global variables bound externally via Guml.GlobalRefs . The scope is the entire guml file. Among them, $controller
always points to the instance of the controller class corresponding to the current guml file.
Used in each
node to represent each
parameter. Its scope is only within the corresponding each
node.
A GUML document may have one or more imports at the top of the file.
Syntax:
import <guml path>
import_top <guml path>
guml path
is a string, path to the guml file to load. Can be an absolute path or a relative path to the current file.
import
will mount the loaded component under the current node, while import_top
will mount it on the root node.
Used to redirect the controller corresponding to the current guml file.
Syntax:
redirect <redirect controller>
redirect controller
is a string, the type name of the redirected controller.
Syntax:
<alias name> <component type> {
<property name>: <property value>,
<signal name>: <method name>
}
alias name
component type
must start with capital letter. Its value can be the component name of any UI component supported by Godot.property name
property value
signal name
is the signal name supported by the current component. It must start with#
and be named using the underscore notation.method name
is a string whose value corresponds to the method name.
string
: Similar to C#'sstring
.int
: Similar to C#'sint
.float
: Similar to C#'sfloat
. Does not support scientific notation.boolean
:true
orfalse
.object
:{ <property name>: <property value> }
ref
: All variable refnull
vector2
:vec2(x: int, y: int)
used to represent Godot's Vector2.color
:color(r: float, g: float, b: float, a: float)
used to represent Godot's Color.styleBox
:style_box_empty()
style_box_flat(properties: object)
style_box_line(properties: object)
style_box_texture(properties: object)
used to represent Godot's StyleBox.resource
:resource(path: string)
used to represent fonts, images, or audio.
Any component declaration can define child components through nested component declarations. In this way, any component declaration implicitly declares an component tree that may contain any number of child components.
Example:
Panel {
Label {
text: "hello"
}
Panel {
Button {}
Button {}
}
}
GUML use the each
syntax to render a list of items based on an DataSource
.
Syntax:
each <data source> { | <index variable define>, <value variable define> |
<each body>
}
data source
can be any variable.index variable define
&&value variable define
Declare local variables of index and value, whose scope is valid throughout each.each body
is multiple component declarations. Note that each cannot be nested directly.
❌Error:
each $controller.DataA { |index_a, value_a|
each $controller.DataB { |index_b, value_b|
// some components
}
}
✔️Right:
each $controller.DataA { |index_a, value_a|
Control {
each $controller.DataB { |index_b, value_b|
// some components
}
}
}
GUML only has single line comments. Single line comments start with // and finish at the end of the line.
Syntax:
// This is a single line comment
import "setting" // This is also allowed
The component's property key cannot conflict with keywords.
import
import_top
redirect
each
resource
vec2
color
style_box_empty
style_box_flat
style_box_line
style_box_texture