Resources.load string + variable

Hi all,

I am trying to do this:

if(rayScript.hitLayer >= 10){
            fileName = textScript.GatherActor(rayScript.hitLayer - 10);
        }
        myaudioClip = (AudioClip)Resources.Load("/Voices/" + fileName)

where myaudioClip is being pulled from my resources folder in my project, but the name of the audio file I want to be my clip changes as I raycast different objects so I put the name in a variable. Is this possible? Is there an easier way to do this?

Thank you all very much

The problem with that is that you’re loading audio files at runtime… potentially a lot of them. Operations that involve your hard drive are among the slowest computer operations, so maybe you can put a public AudioClip in a component on the objects you’re raycasting and copy the audioclip off that component.