This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+2 votes

Does anyone know how to use the ResourcePreloader node properly? I want to preload all textures and whatnot in my scene, but I'm not sure if I'm using it correctly. I can't find any tutorials or info on it, really.

1) Do I just add the resources to the preloader node?
2) Can I just add a whole scene and it will take care of the rest, or do I have to put in every single texture, sound, ext. for it to be preloaded?

in Engine by (33 points)

1 Answer

0 votes

1) Just add the resources via the ResourcePreloader window.

2) I have been utilizing ResourcePreloader for reusable ui widgets, which are saved as .tscn files. As far as i can tell, everything a scene requires is preloaded. (In Video Mem tab of the debugger, unique textures associated with the preloaded scenes are present before they are used.)

When it comes time to instance a preloaded scene:
var widget = get_resource(widget_name).instance()


If you need to add a scene at runtime you can add it with the ResourcePreloader's add_resource function.
Usage example:

func load_and_instance(path):
    var scene
    var name = path.get_file().basename()

    if preloader.has_resource(name):
        scene = preloader.get_resource(name)
    else:
        scene = load(path)
        preloader.add_resource(name, scene)

    return scene.instance()
by (470 points)
edited by

So do you have to instance a scene like you've shown, or can I instance a scene to my current scene, then add that instanced scene to ResourcePreloader?

You can't add instanced scenes. Updating answer with additional information.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.