- Home /
How can I get the file path to an audioclip?
I have an inspector with an AudioClip field. Is there any way to retrieve the file path of the AudioClip that was dragged into the field?
Answer by LandePlage · Dec 27, 2020 at 07:46 PM
You can get the file path to an AudioClip using the AssetDatabase class. For example, using the GetAssetPath method, which takes an instance ID or just the object itself.
string assetPath = AssetDatabase.GetAssetPath(audioSource.clip.GetInstanceID());
https://docs.unity3d.com/ScriptReference/AssetDatabase.GetAssetPath.html
Answer by haizathaneefa · Dec 24, 2020 at 01:19 AM
Hello, your question has been answered here
This seems to be the opposite of my problem. They already know the path and want to create an audio clip from it. In my case, I have the audio clip, but not the path to it.