From 188ee088a231daf4579515461c5718560e16751b Mon Sep 17 00:00:00 2001 From: VaDiM Date: Fri, 8 Nov 2024 20:12:25 +0300 Subject: [PATCH] Improve support of Texture2DArray assets --- AssetStudio/Classes/GLTextureSettings.cs | 10 ++++--- AssetStudio/Classes/Texture2DArray.cs | 33 ++++++++++++++++++++---- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/AssetStudio/Classes/GLTextureSettings.cs b/AssetStudio/Classes/GLTextureSettings.cs index 461a98b..a017771 100644 --- a/AssetStudio/Classes/GLTextureSettings.cs +++ b/AssetStudio/Classes/GLTextureSettings.cs @@ -1,4 +1,6 @@ -namespace AssetStudio +using System.Text.Json.Serialization; + +namespace AssetStudio { public class GLTextureSettings { @@ -6,6 +8,8 @@ public int m_Aniso; public float m_MipBias; public int m_WrapMode; + [JsonInclude] + private int m_WrapU { set => m_WrapMode = value; } public GLTextureSettings() { } @@ -19,8 +23,8 @@ if (version >= 2017)//2017.x and up { m_WrapMode = reader.ReadInt32(); //m_WrapU - int m_WrapV = reader.ReadInt32(); - int m_WrapW = reader.ReadInt32(); + var m_WrapV = reader.ReadInt32(); + var m_WrapW = reader.ReadInt32(); } else { diff --git a/AssetStudio/Classes/Texture2DArray.cs b/AssetStudio/Classes/Texture2DArray.cs index 8d2a997..fcd1006 100644 --- a/AssetStudio/Classes/Texture2DArray.cs +++ b/AssetStudio/Classes/Texture2DArray.cs @@ -23,23 +23,46 @@ namespace AssetStudio public Texture2DArray(ObjectReader reader) : base(reader) { - m_ColorSpace = reader.ReadInt32(); - m_Format = (GraphicsFormat)reader.ReadInt32(); + if (version >= 2019) //2019 and up + { + m_ColorSpace = reader.ReadInt32(); + m_Format = (GraphicsFormat)reader.ReadInt32(); + } m_Width = reader.ReadInt32(); m_Height = reader.ReadInt32(); m_Depth = reader.ReadInt32(); + if (version < 2019) //2019 down + { + m_Format = (GraphicsFormat)reader.ReadInt32(); + } m_MipCount = reader.ReadInt32(); + if (version >= (2023, 2)) //2023.2 and up + { + var m_MipsStripped = reader.ReadInt32(); + } m_DataSize = reader.ReadUInt32(); m_TextureSettings = new GLTextureSettings(reader); + if (version < 2019) //2019 down + { + m_ColorSpace = reader.ReadInt32(); + } if (version >= (2020, 2)) //2020.2 and up { var m_UsageMode = reader.ReadInt32(); } var m_IsReadable = reader.ReadBoolean(); - reader.AlignStream(); - + if (version > (2023, 2)) //2023.2 and up + { + var m_IgnoreMipmapLimit = reader.ReadBoolean(); + reader.AlignStream(); + var m_MipmapLimitGroupName = reader.ReadAlignedString(); + } + else + { + reader.AlignStream(); + } var image_data_size = reader.ReadInt32(); - if (image_data_size == 0) + if (image_data_size == 0 && version >= (5, 6)) //5.6 and up { m_StreamData = new StreamingInfo(reader); }