hey there - kinda tearing my hair out on the proper C# casting to return an array of Audio Sources. it may be that Unity 4 may have changed format a bit.
i set up my audio source variables in the usual way:
AudioSource source1;
AudioSource source2;
private AudioSource[] sources;
public GameObject playlistObj;
void Start(){
sources = (AudioSource[])playlistObj.GetComponents(typeof (AudioSource));
source1 = sources[0];
source2 = sources[1];
}
but this method while giving no syntax errors, returns a failed cast and then a null result later on.
i’ve seen some examples of adding AudioSources to a GameObject, but i’m more interested in retrieving a list of Audio Sources from a given object.
help appreciated!
scott