@@ -58,41 +58,66 @@ Selecting the root "Gui" node in the *Outline* shows the *Properties* for the GU
58
58
59
59
## Runtime manipulation
60
60
61
- You can manipulate GUI properties in runtime using ` go.get() ` and ` go.set() ` :
61
+ You can manipulate GUI properties in runtime from a script component using ` go.get() ` and ` go.set() ` :
62
62
63
63
Fonts
64
64
: Get or set a font used in a GUI.
65
65
66
+ ![ get_set_font] ( images/gui/get_set_font.png )
67
+
66
68
``` lua
67
69
go .property (" mybigfont" , resource .font (" /assets/mybig.font" ))
68
70
69
71
function init (self )
70
- local current_font = go .get (" #gui" , " bigfont" )
71
- go .set (" #gui" , " bigfont" , self .mybigfont )
72
+ -- get the font currently assigned to the font property 'default'
73
+ print (go .get (" #gui" , " default" )) -- /builtins/fonts/default.font
74
+
75
+ -- set the font property 'default' to the font assigned to the resource property 'mybigfont'
76
+ go .set (" #gui" , " default" , self .mybigfont )
77
+
78
+ -- get the new font assigned to the font property 'default'
79
+ print (go .get (" #gui" , " default" )) -- /assets/mybig.font
72
80
end
73
81
```
74
82
75
83
Materials
76
84
: Get or set a material used in a GUI.
77
85
86
+ ![ get_set_material] ( images/gui/get_set_material.png )
87
+
78
88
``` lua
79
- go .property (" mymaterial " , resource .font (" /assets/my .material" ))
89
+ go .property (" myeffect " , resource .font (" /assets/myeffect .material" ))
80
90
81
91
function init (self )
82
- local current_material = go .get (" #gui" , " specialmaterial" )
83
- go .set (" #gui" , " specialmaterial" , self .mymaterial )
92
+ -- get the material currently assigned to the material property 'effect'
93
+ print (go .get (" #gui" , " effect" )) -- /effect.material
94
+
95
+ -- set the material property 'effect' to the material assigned to the resource property 'myeffect'
96
+ go .set (" #gui" , " effect" , self .myeffect )
97
+
98
+ -- get the new material assigned to the material property 'effect'
99
+ print (go .get (" #gui" , " effect" )) -- /assets/myeffect.material
84
100
end
85
101
```
86
102
87
103
Textures
88
104
: Get or set a texture (atlas) used in a GUI.
89
105
106
+ ![ get_set_texture] ( images/gui/get_set_texture.png )
107
+
90
108
``` lua
91
- go .property (" myatlas " , resource .font (" /assets/my .atlas" ))
109
+ go .property (" mytheme " , resource .font (" /assets/mytheme .atlas" ))
92
110
93
111
function init (self )
94
- local current_atlas = go .get (" #gui" , " theme" )
95
- go .set (" #gui" , " theme" , self .myatlas )
112
+ -- get the texture currently assigned to the texture property 'theme'
113
+ print (go .get (" #gui" , " theme" )) -- /theme.atlas
114
+
115
+ -- set the texture property 'theme' to the texture assigned to the resource property 'mytheme'
116
+ go .set (" #gui" , " theme" , self .mytheme )
117
+
118
+ -- get the new texture assigned to the texture property 'theme'
119
+ print (go .get (" #gui" , " theme" )) -- /assets/mytheme.atlas
120
+
96
121
end
97
122
```
98
123
0 commit comments