コード例 #1
0
        private static void MP3TurnWAV()
        {
            List <string> paths = EditorExtension.GetSelectionPath();

            string rootPath = ProjectPath.GetDataPath.Substring(0, ProjectPath.GetDataPath.Length - 6);

            for (int i = 0; i < paths.Count; i++)
            {
                if (Directory.Exists(paths[i]))
                {
                    DirectoryInfo info = new DirectoryInfo(rootPath + paths[i]);

                    string savePath = info.FullName + "_WAV";

                    Project.CreateDirectory(savePath);

                    Loom.RunAsync(() =>
                    {
                        List <string> strs = Project.DirectoryAllFileNames(info.FullName, new List <string>()
                        {
                            "mp3"
                        });

                        AudioConverter.MP3TurnWAV(info.FullName, savePath, strs);
                    });
                }
                else if (File.Exists(paths[i]))
                {
                    FileInfo info     = new FileInfo(rootPath + paths[i]);
                    string[] fileName = info.Name.Split('.');

                    if (fileName[fileName.Length - 1] == "mp3")
                    {
                        string savePath = string.Format("{0}/{1}.wav", info.Directory.FullName, fileName[0]);

                        AudioConverter.MP3TurnWAV(info.FullName, savePath);
                        AssetDatabase.Refresh();
                    }
                }
            }
        }
コード例 #2
0
ファイル: AudioRecord.cs プロジェクト: yangjiqiu/Epitome
 /// <summary>
 /// 转换写入音频
 /// </summary>
 static void ConvertAndWrite(FileStream varFileStream, AudioClip tempClip)
 {
     byte[] tempByte = AudioConverter.Convert(tempClip);
     varFileStream.Write(tempByte, 0, tempByte.Length);
 }