(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();
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;
}

View File

@ -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<int> m_class_ids = new List<int> ();
Dictionary<int, byte[]> m_hashes = new Dictionary<int, byte[]> ();
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 IDictionary<int, byte[]> Hashes { get { return m_hashes; } }
public IDictionary<int, TypeTree> 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)
{

View File

@ -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);
}
}
}