Skip to content
This repository has been archived by the owner on Jan 21, 2023. It is now read-only.

Support SpriteBone #918

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion AssetStudio/Classes/Sprite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,24 @@ public Rectf(BinaryReader reader)
}
}

public class SpriteBone
{
public string name;
public Vector3 position;
public Quaternion rotation;
public float length;
public int parentId;

public SpriteBone(BinaryReader reader)
{
name = reader.ReadAlignedString();
position = reader.ReadVector3();
rotation = reader.ReadQuaternion();
length = reader.ReadSingle();
parentId = reader.ReadInt32();
}
}

public sealed class Sprite : NamedObject
{
public Rectf m_Rect;
Expand All @@ -205,7 +223,7 @@ public sealed class Sprite : NamedObject
public PPtr<SpriteAtlas> m_SpriteAtlas;
public SpriteRenderData m_RD;
public Vector2[][] m_PhysicsShape;

public SpriteBone[] m_Bones;
public Sprite(ObjectReader reader) : base(reader)
{
m_Rect = new Rectf(reader);
Expand Down Expand Up @@ -255,6 +273,15 @@ public Sprite(ObjectReader reader) : base(reader)
}

//vector m_Bones 2018 and up
if (version[0] >= 2018)
{
var m_BonesSize = reader.ReadInt32();
m_Bones = new SpriteBone[m_BonesSize];
for (int i = 0;i < m_BonesSize;i++)
{
m_Bones[i] = new SpriteBone(reader);
}
}
}
}
}