x


Check any audio isPlaying

Hi guys, is there a way to find out whether any audio is playing?

var otherClip : AudioClip;

function Update (){
    if (!audio.isPlaying){
        audio.clip = otherClip;
        audio.Play();
    }
}

This works only when the script is attached to the gameobject that contains the audio source. If I want to target to another script in another gameobject, i can do this.

if (gameObject.Find("text01").audio.isPlaying) {

  dosomething();

}

But what i really want is to check if any sort of audio is playing in the scene. It can be playing from any gameobject with a audio source attached. If there a way to check it? Sorry for the long winded question. Trying to get my question across as clear as possible. Thanks guys!!

Rgds, James

more ▼

asked Aug 24 '11 at 12:03 AM

James Ser gravatar image

James Ser
37 9 9 11

maybe you can find all the objects that have an AudioSource[] and then use a for to check if a AudioSource is playing

Aug 24 '11 at 11:27 PM Uriel_96
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

I deleted your SPAM

:D

from @Seth-Bergman

more ▼

answered Aug 24 '11 at 12:11 AM

xiangkoe (suspended)

someone delete away the spam please. Thanks.

Aug 24 '11 at 11:02 PM James Ser

this needs to be removed.

Aug 05 '12 at 04:38 AM reptilebeats
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1026
x11

asked: Aug 24 '11 at 12:03 AM

Seen: 1530 times

Last Updated: Aug 05 '12 at 05:08 AM