(Unity): workaround for a certain asset version.

This commit is contained in:
morkt 2018-03-17 12:18:42 +04:00
parent 44e74d68b3
commit add376037f
3 changed files with 19 additions and 17 deletions

View File

@ -165,15 +165,22 @@ namespace GameRes.Formats.Unity
{ {
var tex = new Texture2D(); var tex = new Texture2D();
tex.Load (input); 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 { if (asset.Tree.Version == "2017.2.0f3")
Name = tex.m_Name, input.ReadInt64();
Type = "image", var stream_data = new StreamingInfo();
Offset = tex.m_StreamData.Offset, stream_data.Load (input);
Size = tex.m_StreamData.Size, if (!string.IsNullOrEmpty (stream_data.Path))
Bundle = GetBundle (tex.m_StreamData.Path), {
}; entry = new AssetEntry {
Name = tex.m_Name,
Type = "image",
Offset = stream_data.Offset,
Size = stream_data.Size,
Bundle = GetBundle (stream_data.Path),
};
}
} }
break; break;
} }

View File

@ -40,7 +40,6 @@ namespace GameRes.Formats.Unity
{ {
internal class Asset internal class Asset
{ {
int m_header_size;
int m_format; int m_format;
uint m_data_offset; uint m_data_offset;
bool m_is_little_endian; bool m_is_little_endian;
@ -58,7 +57,7 @@ namespace GameRes.Formats.Unity
public void Load (AssetReader input) public void Load (AssetReader input)
{ {
m_header_size = input.ReadInt32(); input.ReadInt32(); // header_size
input.ReadUInt32(); // file_size input.ReadUInt32(); // file_size
m_format = input.ReadInt32(); m_format = input.ReadInt32();
m_data_offset = input.ReadUInt32(); m_data_offset = input.ReadUInt32();
@ -330,10 +329,12 @@ namespace GameRes.Formats.Unity
internal class UnityTypeData internal class UnityTypeData
{ {
string m_version;
List<int> m_class_ids = new List<int> (); List<int> m_class_ids = new List<int> ();
Dictionary<int, byte[]> m_hashes = new Dictionary<int, byte[]> (); Dictionary<int, byte[]> m_hashes = new Dictionary<int, byte[]> ();
Dictionary<int, TypeTree> m_type_trees = new Dictionary<int, TypeTree> (); Dictionary<int, TypeTree> m_type_trees = new Dictionary<int, TypeTree> ();
public string Version { get { return m_version; } }
public IList<int> ClassIds { get { return m_class_ids; } } public IList<int> ClassIds { get { return m_class_ids; } }
public IDictionary<int, byte[]> Hashes { get { return m_hashes; } } public IDictionary<int, byte[]> Hashes { get { return m_hashes; } }
public IDictionary<int, TypeTree> TypeTrees { get { return m_type_trees; } } public IDictionary<int, TypeTree> TypeTrees { get { return m_type_trees; } }
@ -341,7 +342,7 @@ namespace GameRes.Formats.Unity
public void Load (AssetReader reader) public void Load (AssetReader reader)
{ {
int format = reader.Format; int format = reader.Format;
var version = reader.ReadCString(); m_version = reader.ReadCString();
var platform = reader.ReadInt32 (); var platform = reader.ReadInt32 ();
if (format >= 13) if (format >= 13)
{ {

View File

@ -68,7 +68,6 @@ namespace GameRes.Formats.Unity
public int m_LightFormat; public int m_LightFormat;
public int m_ColorSpace; public int m_ColorSpace;
public byte[] m_Data; public byte[] m_Data;
public StreamingInfo m_StreamData;
public void Load (AssetReader reader) public void Load (AssetReader reader)
{ {
@ -92,11 +91,6 @@ namespace GameRes.Formats.Unity
m_ColorSpace = reader.ReadInt32(); m_ColorSpace = reader.ReadInt32();
int length = reader.ReadInt32(); int length = reader.ReadInt32();
m_Data = reader.ReadBytes (length); m_Data = reader.ReadBytes (length);
if (0 == length)
{
m_StreamData = new StreamingInfo();
m_StreamData.Load (reader);
}
} }
} }