-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Description
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:
class MainScene extends Scene {
override function preload() {
// These work normally.
var sounds = [Sounds.MUSIC__T5___TIAMAT, Sounds.MUSIC__T5___TIAMAT];
for (sound in sounds) {
assets.add(sound);
}
}
override function update(delta:Float) {
if (status != PRELOAD) {
checkForNewSong();
}
}
/**
* Scans the `assets/music` directory for new files
*/
function checkForNewSong() {
for (song in sys.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 (@:privateAccess assets.assetsByKindAndName.get("sound").get('music/$_song') == null) {
log.info('Found song $song');
addSound(song);
}
}
}
function addSound(sound:String) {
var _sound = sound.split(".")[0]; // Removes file extension.
var id = '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
Heres a video showcasing the issue.
sound_issue_repro.mp4
azcguy
Metadata
Metadata
Assignees
Labels
No labels