Skip to reading
Images, Carousels & Choice Controls

Change an image 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 illustrations

Use Change GUI Element Property when a story event should replace a picture. This complete GDScript example changes the key to a notebook:

Code example
extends "res://scripts/runtime/script_base.gd"
Code example
func run(_context: Dictionary = {}) -> Variant:
    await ChangeGUIElementProperty({
        "guiId": "image_lab",
        "elementId": "inspect_image",
        "property": "assetId",
        "value": "notebook_art"
    })
    return true

Figure 11. The same Image element now displays the notebook as its normal foreground.

Create a script record, Apply Changes, then assign it to a Button or story interaction. The GUI owns the element; the new value is an image asset ID. Use backgroundImageAssetId instead of assetId when you intend to change only the background layer.

Keep the element ID stable. Replacing its picture does not require deleting the element and creating a new one in the designer. Existing event and layout references can continue to point to inspect_image.

Page 15 of 52Permalink
Go to page