(Texture2D): updated deserializer.

This commit is contained in:
morkt 2018-10-04 07:54:07 +04:00
parent 187d4bd4f2
commit f376104f47

View File

@ -64,7 +64,7 @@ namespace GameRes.Formats.Unity
public int m_TextureDimension; public int m_TextureDimension;
public int m_FilterMode; public int m_FilterMode;
public int m_Aniso; public int m_Aniso;
public int m_MipBias; public float m_MipBias;
public int m_WrapMode; public int m_WrapMode;
public int m_LightFormat; public int m_LightFormat;
public int m_ColorSpace; public int m_ColorSpace;
@ -90,13 +90,46 @@ namespace GameRes.Formats.Unity
m_TextureDimension = reader.ReadInt32(); m_TextureDimension = reader.ReadInt32();
m_FilterMode = reader.ReadInt32(); m_FilterMode = reader.ReadInt32();
m_Aniso = reader.ReadInt32(); m_Aniso = reader.ReadInt32();
m_MipBias = reader.ReadInt32(); m_MipBias = reader.ReadFloat();
m_WrapMode = reader.ReadInt32(); m_WrapMode = reader.ReadInt32();
m_LightFormat = reader.ReadInt32(); m_LightFormat = reader.ReadInt32();
m_ColorSpace = reader.ReadInt32(); m_ColorSpace = reader.ReadInt32();
m_DataLength = reader.ReadInt32(); m_DataLength = reader.ReadInt32();
} }
public void Load (AssetReader reader, string version)
{
if (version != "2017.3.1f1")
{
Load (reader);
if (0 == m_DataLength && version.StartsWith ("2017.")) // "2017.2.0f3" || "2017.1.1p1"
reader.ReadInt64();
return;
}
m_Name = reader.ReadString();
reader.Align();
reader.ReadInt32(); // m_ForcedFallbackFormat
reader.ReadInt32(); // m_DownscaleFallback
m_Width = reader.ReadInt32();
m_Height = reader.ReadInt32();
m_CompleteImageSize = reader.ReadInt32();
m_TextureFormat = (TextureFormat)reader.ReadInt32();
m_MipCount = reader.ReadInt32();
m_IsReadable = reader.ReadBool();
reader.Align();
m_ImageCount = reader.ReadInt32();
m_TextureDimension = reader.ReadInt32();
m_FilterMode = reader.ReadInt32();
m_Aniso = reader.ReadInt32();
m_MipBias = reader.ReadFloat();
m_WrapMode = reader.ReadInt32(); // m_WrapU
reader.ReadInt32(); // m_WrapV
reader.ReadInt32(); // m_WrapW
reader.ReadInt32(); // m_LightmapFormat
m_ColorSpace = reader.ReadInt32();
m_DataLength = reader.ReadInt32();
}
public void LoadData (AssetReader reader) public void LoadData (AssetReader reader)
{ {
m_Data = reader.ReadBytes (m_DataLength); m_Data = reader.ReadBytes (m_DataLength);
@ -270,4 +303,32 @@ namespace GameRes.Formats.Unity
} }
} }
} }
/*
--- Texture2D --- 2017.3.1f1 ---
string m_Name
int m_ForcedFallbackFormat
int m_DownscaleFallback
int m_Width
int m_Height
int m_CompleteImageSize
int m_TextureFormat
int m_MipCount
bool m_IsReadable
int m_ImageCount
int m_TextureDimension
GLTextureSettings m_TextureSettings // sizeof = 0x18
int m_FilterMode
int m_Aniso
float m_MipBias
int m_WrapU
int m_WrapV
int m_WrapW
int m_LightmapFormat
int m_ColorSpace
byte[] image data // int + byte[]
StreamingInfo m_StreamData
uint offset
uint size
string path
*/
} }