Esempio n. 1
0
    void SetSongData()
    {
        string dest = GameManager.instance.song;

        if (string.IsNullOrEmpty(dest))
        {
#if UNITY_EDITOR
            dest = EditorUtility.OpenFilePanel("Import Song", Environment.GetFolderPath(Environment.SpecialFolder.MyMusic), "mp3,wav,aac,ogg,wma,flac,alac,aif,mid");
#endif
        }

        FileInfo info    = new FileInfo(dest);
        string   newDest = Path.Combine(Application.streamingAssetsPath, info.Name);
        File.Copy(dest, newDest);

        if (File.Exists(Path.Combine(Application.streamingAssetsPath, info.Name)))
        {
            var www = new WWW("file://" + Path.Combine(Application.streamingAssetsPath, info.Name));
            source.clip = NAudioPlayer.LoadFromMp3(www.bytes);;
            File.Delete(newDest);
        }

        GC.Collect();
    }