public IReadOnlyList <byte> GetAudioData() { if (IsReadLoadType(File.Version)) { using (ResourcesFile res = File.Collection.FindResourcesFile(File, FSBResource.Source)) { if (res == null) { return(new byte[0]); } if (StreamedResource.IsReadSize(File.Version)) { byte[] data = new byte[FSBResource.Size]; using (PartialStream resStream = new PartialStream(res.Stream, res.Offset, res.Size)) { resStream.Position = FSBResource.Offset; resStream.ReadBuffer(data, 0, data.Length); } return(data); } else { return(new byte[0]); } } } else { if (IsReadStreamingInfo(File.Version)) { if (LoadType == AudioClipLoadType.Streaming) { if (m_audioData == null) { using (ResourcesFile res = File.Collection.FindResourcesFile(File, StreamingInfo.Path)) { if (res == null) { return(new byte[0]); } byte[] data = new byte[FSBResource.Size]; using (PartialStream resStream = new PartialStream(res.Stream, res.Offset, res.Size)) { resStream.Position = StreamingInfo.Offset; resStream.ReadBuffer(data, 0, data.Length); } return(data); } } } } return(m_audioData); } }
public byte[] GetContent(ISerializedFile file) { IResourceFile res = file.Collection.FindResourceFile(Path); if (res == null) { return(null); } byte[] data = new byte[Size]; using (PartialStream resStream = new PartialStream(res.Stream, res.Offset, res.Size)) { resStream.Position = Offset; resStream.ReadBuffer(data, 0, data.Length); } return(data); }
public IReadOnlyList <byte> GetImageData() { byte[] data = m_imageData; if (IsReadStreamData(File.Version)) { if (StreamData.Path != string.Empty) { if (m_imageData.Length != 0) { throw new Exception($"Texture '{ValidName}' contains both data and resource path"); } using (ResourcesFile res = File.Collection.FindResourcesFile(File, StreamData.Path)) { if (res != null) { data = new byte[StreamData.Size]; using (PartialStream resStream = new PartialStream(res.Stream, res.Offset, res.Size)) { resStream.Position = StreamData.Offset; resStream.ReadBuffer(data, 0, data.Length); } } } } } if (IsSwapBytes(File.Platform, TextureFormat)) { for (int i = 0; i < data.Length; i += 2) { byte b = data[i]; data[i] = data[i + 1]; data[i + 1] = b; } } return(data); }