Preload only loading once, right?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By pferft

Hi everyone,

A script calls a function in another Node's script 10 times in a row (each time interrupted by a short 0.1 yield).

extends Node2D

func _call_me_10_times():
	var something = preload("res://scene/path.tscn").instance()

	call_deferred("add_child", something)

I just want to be sure: that preload is still being loaded only once, right? Not 10 times. A load would be loaded 10 times, but not a preload, right?

:bust_in_silhouette: Reply From: Enfyna

Resources — Godot Engine (3.3) documentation in English

On the last paragraph it says

without having to load them again from disk each time.

So yeah preload loads the scene at compile time so it doesnt load it every time you call it.

For some reason I just really needed that confirmation, thank you very much.

pferft | 2023-07-13 20:53