Skip to reading
The GUI Designer

17. Change a GUI from a script

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView PDF page

Use Show GUI and Hide GUI when you only need visibility. Use Change GUI Element Property for a child control, and Change GUI Property for the window or a GUI custom property.

Code example
extends "res://scripts/runtime/script_base.gd"
Code example
func run(_event: Dictionary = {}) -> Variant:
    await ChangeGUIElementProperty({
        "guiId": "adventure_hud",
        "elementId": "hint_label",
        "property": "text",
        "value": "Ready to explore"
    })
    await ShowGUI({"guiId": "workshop_menu"})
    return true

1. Create a GDScript record using this source, with an ID such as update_hud.

2. Validate and apply the script, then save the project.

3. Call it from the desired GUI event using a script-running behavior/action, or from an existing action list.

4. In gameplay, check that Hint Label changes and Workshop Menu opens.

Source table from 17. Change a GUI from a script, page 35
TaskAction family
Show/hide a whole interfaceShow GUI / Hide GUI
Show/hide one control or groupShow GUI Element / Hide GUI Element
Make a visible control unavailableDisable GUI Element; use Enable GUI Element to restore it.
Change text, images, colors or geometryChange GUI Element Property
Change a window appearance/custom valueChange GUI Property

Runtime property changes affect the running interface. They do not rewrite the saved authoring layout. Keep starting values in the designer and use runtime actions for changes that happen during play.

Page 35 of 57Permalink
Go to page