What does the Background Resource Loader do

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

My question does the resource loader just load a new scene inside another one, or does it act like the get_tree.change_scene function that completely changes your scene.

:bust_in_silhouette: Reply From: Wakatta

Answer

Loads a PackedScene in the background.

Load

Load() gets a PackedScene from .res, .tscn, .scn to be instanced however when used on large scenes or multiple scenes in succession a noticible game freeze can be observed.

#Usage
func _ready():
    var packed_scene = load("scene.tscn")
    var scene = packed_scene.instance()
    get_tree.change_scene(scene)

Preload

Same as Load() but does all the loading at game start instead. This works really well for small projects, not so much when you have 50+ scenes and your game takes forever to start.

#Usage
var packed_scene = preload("scene.tscn")

func _ready():
    var scene = packed_scene.instance()
    get_tree.change_scene(scene)

Background Resources Loader

This as the name suggests is more thread wise and prepares a scene for use while your game is doing something else (for example showing a video or ad or loading screen)

Clarity

All of the above do the same thing in different ways, give you a PackedScene.

It does not.

  • add the scene to the sceneTree
  • change the current scene
  • create an instance

Additional reading

Background Resources Loading