public void playSound() { if (!wave) { wave = GetComponentInChildren <BubbleWave>(); } if (!audioSource) { audioSource = GetComponent <AudioSource>(); } if (nextBubbles.Count == 1) { Debug.Log("Playing sound 1 next"); audioSource.loop = false; audioSource.Play(); Invoke("playNext", audioSource.clip.length); wave.playSound(); } else { Debug.Log("Playing sound "); audioSource.loop = true; audioSource.Play(); wave.playSound(); } }
// Use this for initialization void Start() { changeColor(selectedColor); mesh = GetComponent <Renderer>(); audioSource = GetComponent <AudioSource>(); anim = GetComponent <Animator>(); nextBubbles = new List <Bubble>(); wave = GetComponentInChildren <BubbleWave>(); if (wave) { wave.playSound(); } scaleUnit = 1.1f; selectedColor = Color.RED; }