From add376037fec3f26009dfdbede9d1e9d1f81fa45 Mon Sep 17 00:00:00 2001 From: morkt Date: Sat, 17 Mar 2018 12:18:42 +0400 Subject: [PATCH] (Unity): workaround for a certain asset version. --- ArcFormats/Unity/ArcASSET.cs | 23 +++++++++++++++-------- ArcFormats/Unity/Asset.cs | 7 ++++--- ArcFormats/Unity/Texture2D.cs | 6 ------ 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/ArcFormats/Unity/ArcASSET.cs b/ArcFormats/Unity/ArcASSET.cs index 81d924bd..f5c63c47 100644 --- a/ArcFormats/Unity/ArcASSET.cs +++ b/ArcFormats/Unity/ArcASSET.cs @@ -165,15 +165,22 @@ namespace GameRes.Formats.Unity { var tex = new Texture2D(); tex.Load (input); - if (tex.m_StreamData != null && !string.IsNullOrEmpty (tex.m_StreamData.Path)) + if (null == tex.m_Data || 0 == tex.m_Data.Length) { - entry = new AssetEntry { - Name = tex.m_Name, - Type = "image", - Offset = tex.m_StreamData.Offset, - Size = tex.m_StreamData.Size, - Bundle = GetBundle (tex.m_StreamData.Path), - }; + if (asset.Tree.Version == "2017.2.0f3") + input.ReadInt64(); + var stream_data = new StreamingInfo(); + stream_data.Load (input); + if (!string.IsNullOrEmpty (stream_data.Path)) + { + entry = new AssetEntry { + Name = tex.m_Name, + Type = "image", + Offset = stream_data.Offset, + Size = stream_data.Size, + Bundle = GetBundle (stream_data.Path), + }; + } } break; } diff --git a/ArcFormats/Unity/Asset.cs b/ArcFormats/Unity/Asset.cs index b9d4de68..4996ace0 100644 --- a/ArcFormats/Unity/Asset.cs +++ b/ArcFormats/Unity/Asset.cs @@ -40,7 +40,6 @@ namespace GameRes.Formats.Unity { internal class Asset { - int m_header_size; int m_format; uint m_data_offset; bool m_is_little_endian; @@ -58,7 +57,7 @@ namespace GameRes.Formats.Unity public void Load (AssetReader input) { - m_header_size = input.ReadInt32(); + input.ReadInt32(); // header_size input.ReadUInt32(); // file_size m_format = input.ReadInt32(); m_data_offset = input.ReadUInt32(); @@ -330,10 +329,12 @@ namespace GameRes.Formats.Unity internal class UnityTypeData { + string m_version; List m_class_ids = new List (); Dictionary m_hashes = new Dictionary (); Dictionary m_type_trees = new Dictionary (); + public string Version { get { return m_version; } } public IList ClassIds { get { return m_class_ids; } } public IDictionary Hashes { get { return m_hashes; } } public IDictionary TypeTrees { get { return m_type_trees; } } @@ -341,7 +342,7 @@ namespace GameRes.Formats.Unity public void Load (AssetReader reader) { int format = reader.Format; - var version = reader.ReadCString(); + m_version = reader.ReadCString(); var platform = reader.ReadInt32 (); if (format >= 13) { diff --git a/ArcFormats/Unity/Texture2D.cs b/ArcFormats/Unity/Texture2D.cs index 5bea52ac..a48baf42 100644 --- a/ArcFormats/Unity/Texture2D.cs +++ b/ArcFormats/Unity/Texture2D.cs @@ -68,7 +68,6 @@ namespace GameRes.Formats.Unity public int m_LightFormat; public int m_ColorSpace; public byte[] m_Data; - public StreamingInfo m_StreamData; public void Load (AssetReader reader) { @@ -92,11 +91,6 @@ namespace GameRes.Formats.Unity m_ColorSpace = reader.ReadInt32(); int length = reader.ReadInt32(); m_Data = reader.ReadBytes (length); - if (0 == length) - { - m_StreamData = new StreamingInfo(); - m_StreamData.Load (reader); - } } }