From 1d93d3e8659bd7544a02091063dab24a326c8b59 Mon Sep 17 00:00:00 2001 From: Tellow Krinkle Date: Sat, 20 Jul 2019 22:16:03 +0900 Subject: [PATCH] Add binary templates for unity sprites --- scripts/BinaryTemplates/Readme.md | 6 ++ scripts/BinaryTemplates/Unity5.2Sprite.tcl | 79 +++++++++++++++ scripts/BinaryTemplates/Unity5.3Sprite.tcl | 81 +++++++++++++++ scripts/BinaryTemplates/Unity5.5Sprite.tcl | 83 ++++++++++++++++ scripts/BinaryTemplates/Unity5.6Sprite.tcl | 110 +++++++++++++++++++++ 5 files changed, 359 insertions(+) create mode 100644 scripts/BinaryTemplates/Readme.md create mode 100644 scripts/BinaryTemplates/Unity5.2Sprite.tcl create mode 100644 scripts/BinaryTemplates/Unity5.3Sprite.tcl create mode 100644 scripts/BinaryTemplates/Unity5.5Sprite.tcl create mode 100644 scripts/BinaryTemplates/Unity5.6Sprite.tcl diff --git a/scripts/BinaryTemplates/Readme.md b/scripts/BinaryTemplates/Readme.md new file mode 100644 index 0000000..9261158 --- /dev/null +++ b/scripts/BinaryTemplates/Readme.md @@ -0,0 +1,6 @@ +# Binary Templates +Binary template files for more easily interpreting things in a hex editor + +Ones with a `.tcl` extension are made for the MacOS editor [Hex Fiend](http://ridiculousfish.com/hexfiend/), though they should be a pretty good basis for anyone trying to make template files for other hex editors + +`Unity5.#Sprite.tcl` files are templates for the modified Unity sprite files held in [`assets/files-5.*/SGCaret*_Sprite.dat`](../../assets) \ No newline at end of file diff --git a/scripts/BinaryTemplates/Unity5.2Sprite.tcl b/scripts/BinaryTemplates/Unity5.2Sprite.tcl new file mode 100644 index 0000000..331881f --- /dev/null +++ b/scripts/BinaryTemplates/Unity5.2Sprite.tcl @@ -0,0 +1,79 @@ +little_endian +proc align {size alignment} { + set extra [expr $size % $alignment] + set newExtra [expr $extra > 0 ? $alignment : 0] + return [expr $size - $extra + $newExtra] +} + +proc alignPos {alignment} { + goto [align [pos] $alignment] +} + +proc pptr {name} { + section $name { + int32 "m_FileID" + int64 "m_PathID" + } +} + +proc rectf {name} { + section $name { + float "x" + float "y" + float "width" + float "height" + } +} + +proc vector2f {name} { + section $name { + float "x" + float "y" + } +} + +proc vector3f {name} { + section $name { + float "x" + float "y" + float "z" + } +} + +proc vector4f {name} { + section $name { + float "x" + float "y" + float "z" + float "w" + } +} + +set nameLen [uint32 "Name Length"] +str [align $nameLen 4] "utf8" "Name" +rectf "m_Rect" +vector2f "m_Offset" +vector4f "m_Border" +float "m_PixelsToUnits" +uint32 "m_Extrude" + +section "m_RD" { + pptr "texture" + pptr "alphaTexture" + section "vertices" { + set alen [int32 "size"] + for {set i 0} {$i < $alen} {incr i} { + vector3f "pos" + } + } + section "indices" { + set alen [int32 "size"] + for {set i 0} {$i < $alen} {incr i} { + uint16 "data" + } + } + rectf "textureRect" + vector2f "textureRectOffset" + uint32 "settingsRaw" + vector4f "uvTransform" +} \ No newline at end of file diff --git a/scripts/BinaryTemplates/Unity5.3Sprite.tcl b/scripts/BinaryTemplates/Unity5.3Sprite.tcl new file mode 100644 index 0000000..998a200 --- /dev/null +++ b/scripts/BinaryTemplates/Unity5.3Sprite.tcl @@ -0,0 +1,81 @@ +little_endian +proc align {size alignment} { + set extra [expr $size % $alignment] + set newExtra [expr $extra > 0 ? $alignment : 0] + return [expr $size - $extra + $newExtra] +} + +proc alignPos {alignment} { + goto [align [pos] $alignment] +} + +proc pptr {name} { + section $name { + int32 "m_FileID" + int64 "m_PathID" + } +} + +proc rectf {name} { + section $name { + float "x" + float "y" + float "width" + float "height" + } +} + +proc vector2f {name} { + section $name { + float "x" + float "y" + } +} + +proc vector3f {name} { + section $name { + float "x" + float "y" + float "z" + } +} + +proc vector4f {name} { + section $name { + float "x" + float "y" + float "z" + float "w" + } +} + +set nameLen [uint32 "Name Length"] +str [align $nameLen 4] "utf8" "Name" +rectf "m_Rect" +vector2f "m_Offset" +vector4f "m_Border" +float "m_PixelsToUnits" +uint32 "m_Extrude" +uint8 "m_IsPolygon" +alignPos 4 + +section "m_RD" { + pptr "texture" + pptr "alphaTexture" + section "vertices" { + set alen [int32 "size"] + for {set i 0} {$i < $alen} {incr i} { + vector3f "pos" + } + } + section "indices" { + set alen [int32 "size"] + for {set i 0} {$i < $alen} {incr i} { + uint16 "data" + } + } + rectf "textureRect" + vector2f "textureRectOffset" + uint32 "settingsRaw" + vector4f "uvTransform" +} \ No newline at end of file diff --git a/scripts/BinaryTemplates/Unity5.5Sprite.tcl b/scripts/BinaryTemplates/Unity5.5Sprite.tcl new file mode 100644 index 0000000..2893769 --- /dev/null +++ b/scripts/BinaryTemplates/Unity5.5Sprite.tcl @@ -0,0 +1,83 @@ +little_endian +proc align {size alignment} { + set extra [expr $size % $alignment] + set newExtra [expr $extra > 0 ? $alignment : 0] + return [expr $size - $extra + $newExtra] +} + +proc alignPos {alignment} { + goto [align [pos] $alignment] +} + +proc pptr {name} { + section $name { + int32 "m_FileID" + int64 "m_PathID" + } +} + +proc rectf {name} { + section $name { + float "x" + float "y" + float "width" + float "height" + } +} + +proc vector2f {name} { + section $name { + float "x" + float "y" + } +} + +proc vector3f {name} { + section $name { + float "x" + float "y" + float "z" + } +} + +proc vector4f {name} { + section $name { + float "x" + float "y" + float "z" + float "w" + } +} + +set nameLen [uint32 "Name Length"] +str [align $nameLen 4] "utf8" "Name" +rectf "m_Rect" +vector2f "m_Offset" +vector4f "m_Border" +float "m_PixelsToUnits" +vector2f "m_Pivot" +uint32 "m_Extrude" +uint8 "m_IsPolygon" +alignPos 4 + +section "m_RD" { + pptr "texture" + pptr "alphaTexture" + section "vertices" { + set alen [int32 "size"] + for {set i 0} {$i < $alen} {incr i} { + vector3f "pos" + } + } + section "indices" { + set alen [int32 "size"] + for {set i 0} {$i < $alen} {incr i} { + uint16 "data" + } + } + rectf "textureRect" + vector2f "textureRectOffset" + vector2f "Unknown" + uint32 "settingsRaw" + vector4f "uvTransform" +} \ No newline at end of file diff --git a/scripts/BinaryTemplates/Unity5.6Sprite.tcl b/scripts/BinaryTemplates/Unity5.6Sprite.tcl new file mode 100644 index 0000000..7672b39 --- /dev/null +++ b/scripts/BinaryTemplates/Unity5.6Sprite.tcl @@ -0,0 +1,110 @@ +little_endian +proc align {size alignment} { + set extra [expr $size % $alignment] + set newExtra [expr $extra > 0 ? $alignment : 0] + return [expr $size - $extra + $newExtra] +} + +proc alignPos {alignment} { + goto [align [pos] $alignment] +} + +proc pptr {name} { + section $name { + int32 "m_FileID" + int64 "m_PathID" + } +} + +proc rectf {name} { + section $name { + float "x" + float "y" + float "width" + float "height" + } +} + +proc vector2f {name} { + section $name { + float "x" + float "y" + } +} + +proc vector3f {name} { + section $name { + float "x" + float "y" + float "z" + } +} + +proc vector4f {name} { + section $name { + float "x" + float "y" + float "z" + float "w" + } +} + +set nameLen [uint32 "Name Length"] +str [align $nameLen 4] "utf8" "Name" +rectf "m_Rect" +vector2f "m_Offset" +vector4f "m_Border" +float "m_PixelsToUnits" +vector2f "m_Pivot" +uint32 "m_Extrude" +uint8 "m_IsPolygon" +alignPos 4 + +section "m_RD" { + pptr "texture" + pptr "alphaTexture" + section "m_SubMeshes" { + set alen [int32 "size"] + for {set i 0} {$i < $alen} {incr i} { + section "Submesh" { + uint32 "firstByte" + uint32 "indexCount" + int32 "topology" + uint32 "firstVertex" + uint32 "vertexCount" + section "localAABB" { + vector3f "m_Center" + vector3f "m_Extent" + } + } + } + } + section "m_IndexBuffer" { + set alen [int32 "size"] + for {set i 0} {$i < $alen} {incr i} { + uint8 "data" + } + } + section "m_VertexData" { + int32 "m_CurrentChannels" + uint32 "m_VertexCount" + section "m_Channels" { + set alen [int32 "size"] + for {set i 0} {$i < $alen} {incr i} { + section "ChannelInfo" { + uint8 "stream" + uint8 "offset" + uint8 "format" + uint8 "dimension" + } + } + } + set dlen [uint32 "dataSize"] + bytes $dlen "data" + } + rectf "textureRect" + vector2f "textureRectOffset" + vector2f "Unknown" + uint32 "settingsRaw" + vector4f "uvTransform" +} \ No newline at end of file