Skip to reading
3D Models & Video in GUIs

20. Build a Play / Restart Button

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

The embedded Video element does not have dedicated shared Play GUI Video / Pause GUI Video action types in this build. A small GDScript wrapper can control its actual player. Create a script record with ID play_video:

Code example
extends "res://scripts/runtime/script_base.gd"
Code example
func run(_context: Dictionary = {}) -> Variant:
    var player := GetGUIElementProperty(
        "video_lab", "briefing_video", "video_player", null
    ) as VideoStreamPlayer
    if player == null or player.stream == null:
        return false
    player.paused = false
    player.play()
    return true

1. Apply Changes to the script.

2. Add a Button with the caption Play / Restart.

3. In Events, set Click to run-visual-script and Click Target to play_video.

4. Start a running game preview, open the GUI and press the Button.

The behavior name run-visual-script can run this GDScript record too. You can also use the shared script-running action that offers the project’s script records.

player.play() starts playback from the beginning. Resuming a paused movie uses a different operation, explained next.

Page 29 of 45Permalink
Go to page