コード例 #1
0
        private byte[] GetRawData(AudioClip clip)
        {
            if (AudioClip.IsReadLoadType(clip.File.Version))
            {
                ResourcesFile res = clip.File.Collection.FindResourcesFile(clip.File, clip.FSBResource.Source);
                if (res == null)
                {
                    Logger.Instance.Log(LogType.Warning, LogCategory.Export, $"Can't export '{clip.Name}' because resources file '{clip.FSBResource.Source}' wasn't found");
                    return(null);
                }

                res.Stream.Position = clip.FSBResource.Offset;
                if (StreamedResource.IsReadSize(clip.File.Version))
                {
                    byte[] buffer = new     byte[clip.FSBResource.Size];
                    res.Stream.Read(buffer, 0, buffer.Length);
                    return(buffer);
                }
                else
                {
                    Logger.Instance.Log(LogType.Warning, LogCategory.Export, $"Can't export '{clip.Name}' because unknown raw data size");
                    return(null);
                }
            }
            else
            {
                return((byte[])clip.AudioData);
            }
        }