Probably this is a bit higher for my skills but lets try.
I have a C# game which works with .wav audio files. The file can be open and play from inside the game. i use a HDD url path (example: C:/music/audioClip.wav ).
void PlayAudioClip ( string path ) { //code...
Using an installer or In windows is simple to associate this particular wav extension to my game.
You have to add registry entries in the installer to associate your program’s file extension with the game application.
So if the player makes double click into a .wav file then opens my game.
My intention is to open and run the file, that in my case read and play the file.
How do I get the path when the wav file is double click?
I found this code
public static void Main(string[] args){
if (args.Length == 0){
// Show your application usage or show an error box
return;
}
string file = args[0];
Application.Run(new MyProgram(file));
}
But I didn’t understand it. I don’t know how to implement it in Unity.
Do I need some extra includes for Application.Run?
The string array args is the file path?
In Unity do I need to get the path in Start() or in Awake()?
Just in case a bit more about play function:
void Start () {
StartCoroutine( PlayWAV ( hddPath ) );
}
IEnumerator PlayWAV ( string path )
{
path = path.Replace('\\', '/');
path = "file:///" + path;
WWW URL = new WWW( path );
yield return URL;
audioSource.clip = URL.GetAudioClip(false,true);
if (audioContainer.clip.loadState == AudioDataLoadState.Loaded &&
path.ToLower().Contains(".wav") )
{
audioSource.Play();
}
}