duck

Unity 3D Javascript finding audio component from multiple

Nov 6th, 2011
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // how to find a particular AudioSource (by clip name) when you have multiple attached
  2.  
  3. function Start() {
  4.     var music : AudioClip;
  5.     for (var src in GetComponents.<AudioSource>()) {
  6.         if (src.clip.name == "music") {
  7.             music = src;
  8.             break;
  9.         }
  10.     }
  11.     music.Play();
  12. }
Advertisement
Add Comment
Please, Sign In to add comment