Merge branch 'Unity2019'

This commit is contained in:
Jáchym Toušek
2022-07-27 08:41:56 +02:00
10 changed files with 169 additions and 15 deletions

View File

@@ -0,0 +1,147 @@
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_RenderDataKey" {
uuid "first"
int64 "second"
}
uint32 "m_AtlasTags.size"
pptr "m_SpriteAtlas"
section "m_RD" {
pptr "texture"
pptr "alphaTexture"
section "secondaryTextures" {
set alen [int32 "size"]
for {set i 0} {$i < $alen} {incr i} {
# TODO: What are these?
}
}
section "m_SubMeshes" {
set alen [int32 "size"]
for {set i 0} {$i < $alen} {incr i} {
section "Submesh" {
uint32 "firstByte"
uint32 "indexCount"
int32 "topology"
uint32 "baseVertex"
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" {
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"
}
section "m_Bindpose" {
set alen [int32 "size"]
for {set i 0} {$i < $alen} {incr i} {
# TODO: What are these
}
}
rectf "textureRect"
vector2f "textureRectOffset"
vector2f "atlasRectOffset"
uint32 "settingsRaw"
vector4f "uvTransform"
float "downscaleMultiplier"
}
section "m_PhysicsShape" {
set alen [int32 "size"]
for {set i 0} {$i < $alen} {incr i} {
section "Entry" {
set blen [int32 "size"]
for {set j 0} {$j < $blen} {incr j} {
vector2f "data"
}
}
}
}
section "m_Bones" {
set alen [int32 "size"]
for {set i 0} {$i < $alen} {incr i} {
# TODO: What are these
}
}

View File

@@ -32,12 +32,17 @@ class AssetEdit:
output = len(self.name).to_bytes(4, byteorder="little")
output += self.name.encode("utf-8")
output += b"\0" * ((4 - len(self.name)) % 4)
if unityVersion[0] == 2019:
output += (4).to_bytes(4, byteorder="little") # m_ForcedFallbackFormat
output += (0).to_bytes(4, byteorder="little") # m_DownscaleFallback
output += image.width.to_bytes(4, byteorder="little")
output += image.height.to_bytes(4, byteorder="little")
output += len(imageData).to_bytes(4, byteorder="little")
output += (4).to_bytes(4, byteorder="little") # m_TextureFormat
output += (1).to_bytes(4, byteorder="little") # m_MipCount
output += b"\0\x01\0\0" # Flags
if unityVersion[0] == 2019:
output += (0).to_bytes(4, byteorder="little") # m_StreamingMipmapsPriority
output += (1).to_bytes(4, byteorder="little") # m_ImageCount
output += (2).to_bytes(4, byteorder="little") # m_TextureDimension
output += (2).to_bytes(4, byteorder="little") # m_FilterMode
@@ -45,7 +50,7 @@ class AssetEdit:
output += (0).to_bytes(4, byteorder="little") # m_MipBias
if unityVersion[0] == 5:
output += (1).to_bytes(4, byteorder="little") # m_WrapMode
elif unityVersion[0] == 2017:
elif unityVersion[0] == 2017 or unityVersion[0] == 2019:
output += (1).to_bytes(4, byteorder="little") * 3 # m_wrap{U,V,W}
else:
sys.stderr.write("Warning: Unrecognized Unity version: " + str(unityVersion[0]))