I have the following script:
public class soundcontrol : MonoBehaviour {
AudioSource theaudio ;
public AudioClip clip1;
public AudioClip clip2;
public AudioClip clip3;
AudioClip[] cliparray;
int currentclip = -1;
int maxclip = 0;
bool isclip1null = false;
bool isclip2null = false;
bool isclip3null = false;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
maxclip = 0;
if (clip1 != null) {
isclip1null = true;
cliparray [maxclip] = clip1;
maxclip = maxclip + 1;
}
if (clip2 != null) {
isclip2null = true;
cliparray [maxclip] = clip2;
maxclip = maxclip + 1;
}
if (clip3 != null) {
isclip3null = true;
cliparray [maxclip] = clip3;
maxclip = maxclip + 1;
}
if (!theaudio.isPlaying) { // the error is here
if (!((maxclip - 1) == -1)) {
currentclip = currentclip + 1;
if (currentclip > maxclip) {
currentclip = 0;
}
if (!((maxclip - 1) == -1)) {
theaudio.PlayOneShot (cliparray [currentclip]);
}
}
}
if ((maxclip - 1) == -1) {
Debug.Log (" no clip attached ");
}
}
}
The error was at theaudio.isPlaying
checking, the method I use is the same as what's in the documentation.
So, why is this thing happening? The documentation is just too bad to be understood (they can use that magic while I can't).
I also have audio source attached.
I'm a beginner with Unity so before you guys downvote please help me solve my problem first, and I'm sorry if this has already been asked somewhere, Google just seems to not give me the answer I want :\
cliparray
in any way... \$\endgroup\$theaudio
in any way... \$\endgroup\$