How to add a resource as a dependency of a scene/node

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

Does anyone know how to add a resource as a ‘dependency’ of a node? That is when that node is loaded (as part of the scene loading) I also want to load some other resources.

Basically I have my splash screen which uses an interactive loader to load the main game scene. The interactive loader loads all the resources all the nodes in the scene need e.g. if I have a Sprite3d with a specific texture that texture is loaded. But if that sprite3d has a script that lets it switch between three other textures those textures won’t be loaded until the first time I try to use them.

I want the interactive loader to recognize those extra textures as ‘dependencies’ of that sprite3d and load them directly.

I’m not sure if this is how preload works but I’m using C#/Mono so I can’t use the preload keyword. (And I haven’t found an equivalent.)

:bust_in_silhouette: Reply From: Moldor2

I guess you could make a script for everything that has those dependencies that holds some code such as:

export(Texture) texture_to_load

then you could call on that custom property in your interactive loader.

I’m confused, what are you talking about? As far as I can tell the documentation on interactive loader doesn’t read random properties of the objects it loads.

You can see for yourself here.

TwentyThirtyZeroSix | 2020-12-03 21:18