Detecting audio file attached to audio source at runtime.

Hi,

My audio sources are created and managed dynamically at runtime, I need to be able to detect the name of the audio file which is attached to the audio source at any time.

I know you can detect the name of the audiosource gameobject using :

if (gameobject.name.Contains("xxxxxx"))

but I need to be able to detect the name of the actual file attached the the audio source

Any help would be appreciated.

Thanks

You can use the clip property of an audio source to get info from the file.

if (audiosource.clip.name.Contains("xxxxx"))

There are more properties on the clip you can access as well.