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
unity3d filesystems assets audioclip
add a comment |
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
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 usefile://
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
add a comment |
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
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
unity3d filesystems assets audioclip
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 usefile://
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
add a comment |
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 usefile://
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
add a comment |
1 Answer
1
active
oldest
votes
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
add a comment |
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
add a comment |
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
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
answered Nov 22 '18 at 4:16
ToxxicToxxic
2215
2215
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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