How to find index of AudioClip in anArrey by its name

How to find index of AudioClip in an Arrey by its name?

AudioClip[ ];

Iterate through the array with a for-loop.

int FindAudioClipIndexByName(string name)
{
   for (int i = 0; i < audioClips.Length; i++)
   {
      if (audioClips[i].name == name)
         return i;
   }
}
1 Like