Skip to reading
GUI Styling, Shaders & Effects

Use a script to change a complete state

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

Changing only the normal background can leave hover and pressed colors in the old palette. This complete GDScript record updates the related colors together:

Code example
extends "res://scripts/runtime/script_base.gd"
Code example
func run(_context: Dictionary = {}) -> Variant:
    var updates: Dictionary = {
        "background": "#713e35",
        "hoverBackground": "#8d5946",
        "pressedBackground": "#542a24",
        "borderColor": "#efc577"
    }
    for property_name: String in updates:
        await ChangeGUIElementProperty({
            "guiId": "style_lab",
            "elementId": "primary_button",
            "property": property_name,
            "value": updates[property_name]
        })
    return true

Create a normal GDScript record, apply it, then assign its ID to the intended script-running event or action. Replace the GUI and element IDs with your own. Do not paste the function into a GUI’s raw element JSON.

Use the same idea for a normal/selected pair of tab styles. Put the change at the point where selection changes, rather than repeatedly rebuilding a whole menu every frame.

These are runtime changes. They do not mean the editor project has been permanently redesigned. Store an important theme choice in supported game settings/variables, reapply it deliberately and test it after loading a save.

Page 52 of 70Permalink
Go to page