Add AudioClip to Inspector Programmatically

Hi there,

I currently have a program that imports a spreadsheet to the editor and creates a new gameobject. Everything works great, except for the field that I want to reference an AudioClip.

Basically any strings get imported fine and I can see their values in the Inspector, but any strings that we try to use as a path for the AudioClip does not seem to work. The Inspector will not show or link to the AudioClip asset in any way.

To try to set the AudioClip we have something such as:

AudioClip myAudio = Resources.Load(currentItem.myFileToLoad, typeof(AudioClip)) as AudioClip;

//myFileToLoad is a string containing the asset name with no extension

Thanks in advance!

If this is an editor script, you can use AssetDatabase.LoadAssetAtPath()