Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
[GI] fix parsing issue with Texture2D.
Browse files Browse the repository at this point in the history
  • Loading branch information
Razmoth committed Jul 15, 2023
1 parent 55e66de commit acbb7e7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion AssetStudio/Classes/Texture2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public sealed class Texture2D : Texture
public ResourceReader image_data;
public StreamingInfo m_StreamData;

private static bool HasGNFTexture(ObjectReader reader) => reader.serializedType.Match("1D52BB98AA5F54C67C22C39E8B2E400F");
public Texture2D(ObjectReader reader) : base(reader)
{
m_Width = reader.ReadInt32();
Expand All @@ -84,6 +85,10 @@ public Texture2D(ObjectReader reader) : base(reader)
if (version[0] > 2 || (version[0] == 2 && version[1] >= 6)) //2.6.0 and up
{
var m_IsReadable = reader.ReadBoolean();
if (reader.Game.Type.IsGI() && HasGNFTexture(reader))
{
var m_IsGNFTexture = reader.ReadBoolean();
}
}
if (version[0] >= 2020) //2020.1 and up
{
Expand All @@ -100,11 +105,15 @@ public Texture2D(ObjectReader reader) : base(reader)
var m_ReadAllowed = reader.ReadBoolean();
}
}
if (version[0] > 2018 || (version[0] == 2018 && version[1] >= 2)) //2018.2 and up
if (version[0] > 2018 || (version[0] == 2018 && version[1] >= 2) || reader.Game.Type.IsGI()) //2018.2 and up
{
var m_StreamingMipmaps = reader.ReadBoolean();
}
reader.AlignStream();
if (reader.Game.Type.IsGI() && HasGNFTexture(reader))
{
var m_TextureGroup = reader.ReadInt32();
}
if (version[0] > 2018 || (version[0] == 2018 && version[1] >= 2)) //2018.2 and up
{
var m_StreamingMipmapsPriority = reader.ReadInt32();
Expand All @@ -128,6 +137,10 @@ public Texture2D(ObjectReader reader) : base(reader)
var image_data_size = reader.ReadInt32();
if (image_data_size == 0 && ((version[0] == 5 && version[1] >= 3) || version[0] > 5))//5.3.0 and up
{
if (reader.Game.Type.IsGI() && HasGNFTexture(reader))
{
var m_externalMipRelativeOffset = reader.ReadUInt32();
}
m_StreamData = new StreamingInfo(reader);
}

Expand Down

0 comments on commit acbb7e7

Please sign in to comment.