- Home /
How to allow users to put audio files into game through documents?
In my game, I would like the player to be able to place audio files(.mp3/ .ogg) into their documents and for the game to play that music in the background.
Please explain thoroughly as I would like to build onto this!
Answer by Melvin8D · Dec 28, 2014 at 07:46 PM
You would probably have to do a script where it detects a name of a file, so you will have to tell the customers that you have to name the file of a certain name so it will work.
try this
#pragma strict
funtion Update () {
if (System.IO.File.Exists("sound.mp3"))
{
audio.Play("sound.mp3")
}
}
So what you'll have to do is wherever it says sound.mp3, you should type the directory where the game is going to be stored and the file name of the sound. So it may look like C:/ProgramData/Game/Assets/sound.mp3 instead of just sound.mp3.
It may work or it may not work.
Ok, thank you for the help, I will try that know, I'm making my game multi-platform, $$anonymous$$ac,Windows and Linux, any way I can get the script to deter$$anonymous$$e the OS and then run to a different directory, such as /home/%user%/Documents??
Your answer
Follow this Question
Related Questions
Does Anyone Have a Halo-Like Scripts? 1 Answer
Already has a definiton for 1 Answer
How to create a Game Tree data structure in Unity. 0 Answers
Javascript error.. insert semicolon?? 2 Answers