unity-game-enginefilesystemsassetsaudioclip

Load a folder of files defined by the user at runtime? Custom radio


I am trying to create custom radio tracks in my Unity game, and I want the user to be able to place audio files in a directory like My Documents/My Games/Unity Game/Custom Sounds/ . Then I want Unity to put all audio clips from this folder into an array for me to use in my code. I have searched but cannot find anything about loading a file you don't know the exact path of, or how many there will be


Solution

  • From @Eddge:

    Yes, use the WWW class. docs.unity3d.com/ScriptReference/WWW-audioClip.html for the URL use file:// then the path of the file, it is important to note that unity only supports some music file formats, depending on the platform. So for example .mp3 will not work if building for windows desktop