Example #1
0
        public bool Export(IExportContainer container, Object asset, string path)
        {
            AudioClip audioClip = (AudioClip)asset;

            if (!audioClip.CheckAssetIntegrity())
            {
                Logger.Log(LogType.Warning, LogCategory.Export, $"Can't export '{audioClip.Name}' because resources file hasn't been found");
                return(false);
            }

            if (IsSupported(audioClip))
            {
                byte[] data = ExportAudio(audioClip);
                if (data == null)
                {
                    Logger.Log(LogType.Warning, LogCategory.Export, $"Unable to convert '{audioClip.ValidName}' to wav");
                    return(false);
                }

                using (Stream fileStream = FileUtils.CreateVirtualFile(path))
                {
                    fileStream.Write(data, 0, data.Length);
                }
            }
            else
            {
                using (Stream fileStream = FileUtils.CreateVirtualFile(path))
                {
                    audioClip.ExportBinary(container, fileStream);
                }
            }
            return(true);
        }