You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to add an asset to a scene during runtime with assets.addSound (or just assets.add), it fails to load the asset.
Code for a repro:
classMainSceneextendsScene {
overridefunctionpreload() {
// These work normally.varsounds= [Sounds.MUSIC__T5___TIAMAT, Sounds.MUSIC__T5___TIAMAT];
for (soundinsounds) {
assets.add(sound);
}
}
overridefunctionupdate(delta:Float) {
if (status!=PRELOAD) {
checkForNewSong();
}
}
/** * Scans the `assets/music` directory for new files*/functioncheckForNewSong() {
for (songinsys.FileSystem.readDirectory("assets/music")) {
// Removes file extension.var_song=song.split(".")[0];
// Checking if this asset exists in the assets object. Feel like a function for this should exist.// If it doesn't exist (or is null), then we found a new sound to load.if (@:privateAccessassets.assetsByKindAndName.get("sound").get('music/$_song') ==null) {
log.info('Found song $song');
addSound(song);
}
}
}
functionaddSound(sound:String) {
var_sound=sound.split(".")[0]; // Removes file extension.varid='sound:music/$_sound';
assets.addSound(id);
assets.load(); // Line 42
}
}
After calling addSound, I get the following in my error log
Failed to load audio at path: music/Kunst ceramic/SoundAsset:112
Failed to load asset music/Kunst (SoundAsset(music/Kunst music/Kunst)) MainScene:42
When trying to add an asset to a scene during runtime with
assets.addSound(or justassets.add), it fails to load the asset.Code for a repro:
After calling
addSound, I get the following in my error logHeres a video showcasing the issue.
sound_issue_repro.mp4