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












1















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










share|improve this question


















  • 2





    This is actually a pretty big question, there are several file browsers you can download from the Unity Asset store, or you can build your own. if you are building your own you can start by using the path provided by the Application.PersistentData Path, and using the classes in System.IO for navigation, and getting a list of files in a directory.

    – Eddge
    Nov 20 '18 at 1:50











  • @Eddge I've got that working, any idea how to turn all found files into audio clips? I'm close but there is no audio, the length of the clip is correct though

    – Toxxic
    Nov 20 '18 at 20:21











  • 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.

    – Eddge
    Nov 21 '18 at 14:41











  • @Eddge that did it, thanks!

    – Toxxic
    Nov 22 '18 at 4:16
















1















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










share|improve this question


















  • 2





    This is actually a pretty big question, there are several file browsers you can download from the Unity Asset store, or you can build your own. if you are building your own you can start by using the path provided by the Application.PersistentData Path, and using the classes in System.IO for navigation, and getting a list of files in a directory.

    – Eddge
    Nov 20 '18 at 1:50











  • @Eddge I've got that working, any idea how to turn all found files into audio clips? I'm close but there is no audio, the length of the clip is correct though

    – Toxxic
    Nov 20 '18 at 20:21











  • 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.

    – Eddge
    Nov 21 '18 at 14:41











  • @Eddge that did it, thanks!

    – Toxxic
    Nov 22 '18 at 4:16














1












1








1








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










share|improve this question














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







unity3d filesystems assets audioclip






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 '18 at 0:52









ToxxicToxxic

2215




2215








  • 2





    This is actually a pretty big question, there are several file browsers you can download from the Unity Asset store, or you can build your own. if you are building your own you can start by using the path provided by the Application.PersistentData Path, and using the classes in System.IO for navigation, and getting a list of files in a directory.

    – Eddge
    Nov 20 '18 at 1:50











  • @Eddge I've got that working, any idea how to turn all found files into audio clips? I'm close but there is no audio, the length of the clip is correct though

    – Toxxic
    Nov 20 '18 at 20:21











  • 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.

    – Eddge
    Nov 21 '18 at 14:41











  • @Eddge that did it, thanks!

    – Toxxic
    Nov 22 '18 at 4:16














  • 2





    This is actually a pretty big question, there are several file browsers you can download from the Unity Asset store, or you can build your own. if you are building your own you can start by using the path provided by the Application.PersistentData Path, and using the classes in System.IO for navigation, and getting a list of files in a directory.

    – Eddge
    Nov 20 '18 at 1:50











  • @Eddge I've got that working, any idea how to turn all found files into audio clips? I'm close but there is no audio, the length of the clip is correct though

    – Toxxic
    Nov 20 '18 at 20:21











  • 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.

    – Eddge
    Nov 21 '18 at 14:41











  • @Eddge that did it, thanks!

    – Toxxic
    Nov 22 '18 at 4:16








2




2





This is actually a pretty big question, there are several file browsers you can download from the Unity Asset store, or you can build your own. if you are building your own you can start by using the path provided by the Application.PersistentData Path, and using the classes in System.IO for navigation, and getting a list of files in a directory.

– Eddge
Nov 20 '18 at 1:50





This is actually a pretty big question, there are several file browsers you can download from the Unity Asset store, or you can build your own. if you are building your own you can start by using the path provided by the Application.PersistentData Path, and using the classes in System.IO for navigation, and getting a list of files in a directory.

– Eddge
Nov 20 '18 at 1:50













@Eddge I've got that working, any idea how to turn all found files into audio clips? I'm close but there is no audio, the length of the clip is correct though

– Toxxic
Nov 20 '18 at 20:21





@Eddge I've got that working, any idea how to turn all found files into audio clips? I'm close but there is no audio, the length of the clip is correct though

– Toxxic
Nov 20 '18 at 20:21













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.

– Eddge
Nov 21 '18 at 14:41





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.

– Eddge
Nov 21 '18 at 14:41













@Eddge that did it, thanks!

– Toxxic
Nov 22 '18 at 4:16





@Eddge that did it, thanks!

– Toxxic
Nov 22 '18 at 4:16












1 Answer
1






active

oldest

votes


















0














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







share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53384715%2fload-a-folder-of-files-defined-by-the-user-at-runtime-custom-radio%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    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







    share|improve this answer




























      0














      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







      share|improve this answer


























        0












        0








        0







        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







        share|improve this answer













        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








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 '18 at 4:16









        ToxxicToxxic

        2215




        2215






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53384715%2fload-a-folder-of-files-defined-by-the-user-at-runtime-custom-radio%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            'app-layout' is not a known element: how to share Component with different Modules

            android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

            WPF add header to Image with URL pettitions [duplicate]