From 22e4b0e8a1452d93a10e3364f4bc15c81f201821 Mon Sep 17 00:00:00 2001 From: VaDiM Date: Wed, 20 May 2026 00:06:27 +0300 Subject: [PATCH] Improve support for Unity 6.5, 6.6+ and some cleanup --- AssetStudio/ClassIDType.cs | 1 + AssetStudio/Classes/AnimationClip.cs | 2 +- AssetStudio/Classes/AnimatorController.cs | 12 ++- AssetStudio/Classes/Sprite.cs | 4 +- AssetStudio/Classes/SpriteAtlas.cs | 109 +++++++++++++++++++--- AssetStudio/Classes/TextureFormat.cs | 32 +++++++ AssetStudio/CommonString.cs | 1 + 7 files changed, 143 insertions(+), 18 deletions(-) diff --git a/AssetStudio/ClassIDType.cs b/AssetStudio/ClassIDType.cs index fc6f25b..97af909 100644 --- a/AssetStudio/ClassIDType.cs +++ b/AssetStudio/ClassIDType.cs @@ -327,6 +327,7 @@ namespace AssetStudio PluginBuildInfo = 382020655, UIAnimationBinder = 382093023, MemorySettings = 387306366, + UIAnimationClip = 392092235, BuildMetaDataImporter = 403037116, BuildInstructionImporter = 403037117, EditorProjectAccess = 426301858, diff --git a/AssetStudio/Classes/AnimationClip.cs b/AssetStudio/Classes/AnimationClip.cs index 080ae2f..bd89e04 100644 --- a/AssetStudio/Classes/AnimationClip.cs +++ b/AssetStudio/Classes/AnimationClip.cs @@ -957,7 +957,7 @@ namespace AssetStudio { isSerializeReferenceCurve = reader.ReadByte(); } - if ((!version.IsAlpha && version >= (6000, 5)) || (version.IsAlpha && version >= (6000, 5, 0, 7))) //6000.5.0a7 and up + if (version >= (6000, 5)) //6000.5.0a7 and up { metaData = reader.ReadUInt16(); } diff --git a/AssetStudio/Classes/AnimatorController.cs b/AssetStudio/Classes/AnimatorController.cs index 095e2e0..e5fd1f8 100644 --- a/AssetStudio/Classes/AnimatorController.cs +++ b/AssetStudio/Classes/AnimatorController.cs @@ -516,7 +516,7 @@ namespace AssetStudio public Vector3[] m_PositionValues; public Vector4[] m_QuaternionValues; public Vector3[] m_ScaleValues; - public int[] m_EntityIdValues; + public ulong[] m_EntityIdValues; public ValueArray(ObjectReader reader) { @@ -566,7 +566,15 @@ namespace AssetStudio reader.AlignStream(); if (version >= (6000, 2)) //6000.2 and up { - m_EntityIdValues = reader.ReadInt32Array(); + var numEntities = reader.ReadInt32(); + var m_EntityIdList = new List(); + for (var i = 0; i < numEntities; i++) + { + m_EntityIdList.Add(version >= (6000, 5) //6000.5 and up + ? reader.ReadUInt64() + : reader.ReadUInt32()); + } + m_EntityIdValues = m_EntityIdList.ToArray(); } } } diff --git a/AssetStudio/Classes/Sprite.cs b/AssetStudio/Classes/Sprite.cs index 083a602..d36810c 100644 --- a/AssetStudio/Classes/Sprite.cs +++ b/AssetStudio/Classes/Sprite.cs @@ -155,7 +155,7 @@ namespace AssetStudio } } - if ((!version.IsAlpha && version >= (6000, 5)) || (version.IsAlpha && version >= (6000, 5, 0, 7))) //6000.5.0a7 and up + if (version >= (6000, 5)) //6000.5.0a7 and up { m_BlendShapes = new BlendShapeData(reader); } @@ -228,7 +228,7 @@ namespace AssetStudio } m_Extrude = reader.ReadUInt32(); - if (version.IsInRange((5, 3), (6000, 5))) //5.3 - 6000.4 + if (version.IsInRange((5, 3), (6000, 5))) //5.3 - 6000.5 down { m_IsPolygon = reader.ReadBoolean(); reader.AlignStream(); diff --git a/AssetStudio/Classes/SpriteAtlas.cs b/AssetStudio/Classes/SpriteAtlas.cs index 4e6eefd..21b9a7d 100644 --- a/AssetStudio/Classes/SpriteAtlas.cs +++ b/AssetStudio/Classes/SpriteAtlas.cs @@ -4,7 +4,83 @@ using System.Text.Json.Serialization; namespace AssetStudio { - public class SpriteAtlasData + public sealed class SpriteBone + { + public string name; + public string guid; + public Vector3 position; + public Quaternion rotation; + public float length; + public int parentId; + public Color color; + + public SpriteBone(ObjectReader reader) + { + name = reader.ReadAlignedString(); + guid = reader.ReadAlignedString(); + position = reader.ReadVector3(); + rotation = reader.ReadQuaternion(); + length = reader.ReadSingle(); + parentId = reader.ReadInt32(); + color = reader.ReadColor4(); + } + } + + public sealed class SpriteInstanceData + { + public string spriteName; + public Rectf rect; + public Vector4 border; + public Vector2 pivot; + public float pixelsToUnits; + public int m_IndexFormat; + public List m_SubMeshes; + public byte[] m_IndexBuffer; + public VertexData m_VertexData; + public Matrix4x4[] m_Bindpose; + public BlendShapeData m_BlendShapes; + public List spriteBones; + public List physicsShape; + + public SpriteInstanceData(ObjectReader reader) + { + spriteName = reader.ReadAlignedString(); + rect = new Rectf(reader); + border = reader.ReadVector4(); + pivot = reader.ReadVector2(); + pixelsToUnits = reader.ReadSingle(); + m_IndexFormat = reader.ReadInt32(); + + var m_SubMeshesCount = reader.ReadInt32(); + m_SubMeshes = new List(); + for (var i = 0; i < m_SubMeshesCount; i++) + { + m_SubMeshes.Add(new SubMesh(reader)); + } + + m_IndexBuffer = reader.ReadUInt8Array(); + reader.AlignStream(); + m_VertexData = new VertexData(reader); + m_Bindpose = reader.ReadMatrixArray(); + m_BlendShapes = new BlendShapeData(reader); + + var spriteBonesCount = reader.ReadInt32(); + spriteBones = new List(); + for (var i = 0; i < spriteBonesCount; i++) + { + spriteBones.Add(new SpriteBone(reader)); + } + + var physicsShapeCount = reader.ReadInt32(); + physicsShape = new List(); + for (var i = 0; i < physicsShapeCount; i++) + { + physicsShape.Add(reader.ReadVector2Array()); + } + } + } + + public sealed class SpriteAtlasData { public PPtr texture; public PPtr alphaTexture; @@ -15,6 +91,7 @@ namespace AssetStudio public float downscaleMultiplier; public SpriteSettings settingsRaw; public List secondaryTextures; + public SpriteInstanceData spriteInstanceData; public SpriteAtlasData(ObjectReader reader) { @@ -32,20 +109,24 @@ namespace AssetStudio settingsRaw = new SpriteSettings(reader); if (version >= (2020, 2)) //2020.2 and up { - var secondaryTexturesSize = reader.ReadInt32(); + var secondaryTexturesCount = reader.ReadInt32(); secondaryTextures = new List(); - for (var i = 0; i < secondaryTexturesSize; i++) + for (var i = 0; i < secondaryTexturesCount; i++) { secondaryTextures.Add(new SecondarySpriteTexture(reader)); } reader.AlignStream(); } + if (version >= (6000, 6)) //6000.6.0a3 and up + { + spriteInstanceData = new SpriteInstanceData(reader); + } } } public sealed class SpriteAtlas : NamedObject { - public List> m_PackedSprites; + public List> m_PackedSprites = new List>(); public string[] m_PackedSpriteNamesToIndex; [JsonConverter(typeof(JsonConverterHelper.RenderDataMapConverter))] public Dictionary, SpriteAtlasData> m_RenderDataMap; @@ -55,18 +136,20 @@ namespace AssetStudio public SpriteAtlas(ObjectReader reader) : base(reader) { - var m_PackedSpritesSize = reader.ReadInt32(); - m_PackedSprites = new List>(); - for (var i = 0; i < m_PackedSpritesSize; i++) + if (version < (6000, 6)) //6000.6 down { - m_PackedSprites.Add(new PPtr(reader)); + var m_PackedSpritesCount = reader.ReadInt32(); + for (var i = 0; i < m_PackedSpritesCount; i++) + { + m_PackedSprites.Add(new PPtr(reader)); + } + + m_PackedSpriteNamesToIndex = reader.ReadStringArray(); } - m_PackedSpriteNamesToIndex = reader.ReadStringArray(); - - var m_RenderDataMapSize = reader.ReadInt32(); + var m_RenderDataMapCount = reader.ReadInt32(); m_RenderDataMap = new Dictionary, SpriteAtlasData>(); - for (var i = 0; i < m_RenderDataMapSize; i++) + for (var i = 0; i < m_RenderDataMapCount; i++) { var first = new Guid(reader.ReadBytes(16)); var second = reader.ReadInt64(); @@ -77,7 +160,7 @@ namespace AssetStudio m_IsVariant = reader.ReadBoolean(); reader.AlignStream(); - if ((!version.IsAlpha && version >= (6000, 5)) || (version.IsAlpha && version >= (6000, 5, 0, 4))) //6000.5.0a4 and up + if (version >= (6000, 5)) //6000.5.0a4 and up { m_Guid = new Guid(reader.ReadBytes(16)); } diff --git a/AssetStudio/Classes/TextureFormat.cs b/AssetStudio/Classes/TextureFormat.cs index 10eb11e..4db8f12 100644 --- a/AssetStudio/Classes/TextureFormat.cs +++ b/AssetStudio/Classes/TextureFormat.cs @@ -279,5 +279,37 @@ /// Four channel (RGBA) texture format, 16-bits unsigned integer per channel. /// RGBA64, + /// + /// Single channel (R) texture format, 8-bits signed integer. + /// + R8_SIGNED, + /// + /// Two channel (RG) texture format, 8-bits signed integer per channel. + /// + RG16_SIGNED, + /// + /// Three channel (RGB) texture format, 8-bits signed integer per channel. + /// + RGB24_SIGNED, + /// + /// Four channel (RGBA) texture format, 8-bits signed integer per channel. + /// + RGBA32_SIGNED, + /// + /// Single channel (R) texture format, 16-bits signed integer. + /// + R16_SIGNED, + /// + /// Two channel (RG) texture format, 16-bits signed integer per channel. + /// + RG32_SIGNED, + /// + /// Three color (RGB) texture format, 16-bits signed integer per channel. + /// + RGB48_SIGNED, + /// + /// Four channel (RGBA) texture format, 16-bits signed integer per channel. + /// + RGBA64_SIGNED, } } diff --git a/AssetStudio/CommonString.cs b/AssetStudio/CommonString.cs index 9bad500..3dd49fb 100644 --- a/AssetStudio/CommonString.cs +++ b/AssetStudio/CommonString.cs @@ -118,6 +118,7 @@ namespace AssetStudio {1169, "RenderingLayerMask"}, {1188, "fixed_array"}, {1200, "EntityId"}, + {1209, "LoadableObjectId"}, }; } }