|
Hey everyone. I'm trying to load a handful of sound files into an array via Javascript but the zeroth spot refuses to cooperate. I have all the sound file's names in a string array and load the audio clip array using a for loop. Initially I thought the problem was the for loop but tried manually loading individual slots and found that all besides the very first slot will load via the script. If I try dragging and dropping a file from the resources folder into the array during runtime it works fine but players obviously can't do that. Has anybody ever run into a problem like this before or does anybody have a possible solution? Here's basically what the JS looks like; then later in Start()... Then in inspector I always see this... Sound size 6 Element 0 None(Audio Clip) Element 1 Fireball_01 Element 2 Roar_01 Element 3 Snarl_01 Element 4 Stomp_01 Element 5 Sword_01 bizarre... Anyways thanks for your help in advance.
(comments are locked)
|
|
I've tried the same thing, but it worked for me. I had problems initially because my sound files were in the wrong folder, so all elements of sound[] became empty - but I had no error messages. When I finnally put the files in the right folder, it worked for all elements of the array. Could the first file name of your list be misspelled, or in a folder other than Resources? Since entry one to five are placed in slot one to five, the only obvious reason for it 'skipping' entry zero is because the name is indeed misspelled or it's not in the correct folder. I'm assuming you have a closing } but you just didn't copy/paste it.
Jun 07 '11 at 02:42 AM
Joshua
You know, I thought so too and tried renaming the file and moving it around but that didn't seem to work. It does the same thing regardless of the file I'm trying to put in it. I'm going to try renaming the array and see if that fixes it or not.
Jun 07 '11 at 02:44 AM
Catsby
I also just straight up tried sound[0] = Resources.Load(filename here); and had the same problem. so weird...
Jun 07 '11 at 02:47 AM
Catsby
So you're saying that if, in the sfile:String[] array you switch "Chime_1" and "Fireball_1" it will still skip over entry zero in the sound:AudioClip[] array and not the first entry which would be expected if it couldn't find "Chime_1"?
Jun 07 '11 at 02:48 AM
Joshua
That is correct. I'm about to just delete the audioclip array and re declare it with a different name.
Jun 07 '11 at 02:53 AM
Catsby
(comments are locked)
|
