I can use live update so far when the assets are already placed in the scene. The problem I want to solve is to dynamically set a sound file that is bundled. I see a lot of options here that mentions storing the resource. So my question is how do you use the resources that are stored outside of setting it in the collection?
I am trying to reduce the amount of sound components I need to add into the scene. Specifically for a html5 game if it makes a difference.
If the liveupdate resource/archive has been downloaded and added, then you should be able to use resource.load to get a custom resource as-is.
However, you are also talking about sound specifically.
We currently have no way of changing which sound is playing for a sound component.
I found a way in this forum though a while back to do this and it works in the project I tested. Though are you saying it doesn’t work with resource.load?
local s = sys.load_resource("yourAudio.wav")
resource.set_sound(go.get("#sound", "sound"), s);
sound.play("#sound")
While I had forgotten about resource.set_sound()
, it is also not exactly the same thing.
In your example you replace the in-memory resource. This has the effect that any sound components that use that resource, will now play another sound.
It might be what you want in your case.