I have a problem with AudioClip arrays;
Here is my code:
public AudioClip[] shootSound;
void Update () {
if(Input.GetMouseButtonDown(0)) {
audio.clip = shootSound[0];
audio.Play();
}
}
Every time I press the button I get this message:
IndexOutOfRangeException: Array index is out of range.
Player.Update () (at Assets/Script/Player/Player.cs:60)
But the sound is playing!
The strage thing is when i trying to get the lenght of the array the debugger is telling me that it doensnt have such a variable but monoDevelop is telling me everything is fine.
Assets/Script/Player/Player.cs(62,46): error CS1061: Type `UnityEngine.AudioClip[]' does not contain a definition for `length' and no extension method `length' of type `UnityEngine.AudioClip[]' could be found (are you missing a using directive or an assembly reference?)
Thanks RaverTiny