Hi I have a small question if I use preload(scene.tscn) and load a scene in a autoload script and after that if I use load(scene.tscn) somewhere else will it load a new scene or just return a reference to it because it’s already in ram?
I didn’t find anything about this in the doc and AI gives conflicted answers
thank you
“Returns a Resource from the filesystem located at the absolute path. Unless it’s already referenced elsewhere (such as in another script or in the scene), the resource is loaded from disk on function call, which might cause a slight delay, especially when loading large scenes.”
preload is a compile-time operation. This means you cannot have a dynamic path there, you HAVE to include a DIRECT path to whatever it is you want to load, so if, for example, you want to preload something like this:
res://path/to/img_" + i + ".png", it will not work.
In those cases, you have to use load, which is a run-time operation.
Both are used for different purposes, it’s not a case of “X is better than Y”.