Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Examples of Yield Function uses in GDScript
extends Node
func my_yielding_function():
print("Hello")
print(yield())
print("World")
func _ready():
var v = my_yielding_function()
v.resume("Awesome")
# **This will print**
#
# Hello
# Awesome
# World
extends Node
func my_timer_function():
print("Hello")
yield(get_tree().create_timer(2.0), "timeout")
print("World")
func _ready():
my_timer_function()
print("Awesome")
# **This will print**
#
# Hello
# Awesome
# World
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment