Skip to content

Instantly share code, notes, and snippets.

@Tatsh
Created November 24, 2013 03:41
Show Gist options
  • Save Tatsh/7623045 to your computer and use it in GitHub Desktop.
Save Tatsh/7623045 to your computer and use it in GitHub Desktop.
# extract Unity3D engine *.assets files
# (c) 2012-10-15 by AlphaTwentyThree of XeNTaX
get EXT extension
if EXT == "resS" # no TOC -> scan
cleanexit
endif
endian big
get FSIZE asize
goto 0xc
get BIAS long
if BIAS != 0 # var1
endian little
goto 0x28
get FILES long
else # var2
goto 0
get INFOSIZE long
get INFO long # actually file size
math INFO -= INFOSIZE
math INFO += 0x15
goto INFO
endian little
get FILES long
endif
for i = 1 <= FILES
set SKIP 0
set EXT ""
set FNAME ""
set WNAME ""
get FID long
get OFFSET long
math OFFSET += BIAS # zero in var2
get SIZE long
get TYPE long
get DUMMY long # same as TYPE (?)
savepos MYOFF
callfunction distTYPE 1
if SKIP == 0
if EXT = ""
set EXT "."
string EXT += TYPE
endif
get FOLDERNAME basename
string FOLDERNAME += "/"
if FNAME == ""
get FNAME basename
string FNAME += "_"
string FNAME += FID
endif
string FNAME += EXT
set WNAME FOLDERNAME
string WNAME += FNAME
if FID == FILES # probably not needed, just a precaution
get SIZE asize
math SIZE -= OFFSET
endif
log WNAME OFFSET SIZE
endif
goto MYOFF
next i
startfunction distTYPE
if TYPE == 1
elif TYPE == 2
elif TYPE == 3
elif TYPE == 4
elif TYPE == 5
elif TYPE == 6
elif TYPE == 7
elif TYPE == 8
elif TYPE == 9
elif TYPE == 10
elif TYPE == 11
elif TYPE == 12
elif TYPE == 13
elif TYPE == 14
elif TYPE == 15
elif TYPE == 16
elif TYPE == 17
elif TYPE == 18
elif TYPE == 19
elif TYPE == 20
elif TYPE == 21
callfunction getname 1
set EXT ".mat"
elif TYPE == 23
elif TYPE == 26
elif TYPE == 28
callfunction getname 1
set EXT ".tex"
elif TYPE == 33
elif TYPE == 43
callfunction getname 1
elif TYPE == 48
callfunction getname 1
set EXT ".shader"
goto OFFSET
get SIZE long
math OFFSET += 4
elif TYPE == 49 # ingame movies/xml/backgrounds
callfunction getname 1
callfunction getType 1
elif TYPE == 54
elif TYPE == 64
elif TYPE == 65
elif TYPE == 74
callfunction getname 1
set EXT ".ani"
elif TYPE == 82
elif TYPE == 83 # can be empty (some pointer maybe)
callfunction getname 1
set TEST SIZE
math TEST -= 0x18
if TEST == 0
set SKIP 1
else
math OFFSET += 0x10
goto OFFSET
get SIZE long
savepos OFFSET
getDstring TYPE2 3
if TYPE2 == "RIF"
set EXT ".wav"
elif TYPE2 == "Ogg"
set EXT ".ogg"
elif TYPE2 == "ID3"
set EXT ".mp3"
else
goto OFFSET
get TYPE2 byte
if TYPE2 == 0xff
set EXT ".mp3"
endif
endif
endif
elif TYPE == 89
callfunction getname 1
elif TYPE == 96
elif TYPE == 108
elif TYPE == 111
elif TYPE == 115
callfunction getname 1
elif TYPE == 123
elif TYPE == 128
callfunction getname 1
set EXT ".ttf"
elif TYPE == 131
elif TYPE == 135
elif TYPE == 150
elif TYPE == 152
callfunction getname 1
math OFFSET += 0x10
math SIZE -= 0x10
set EXT ".ogm"
elif TYPE == 159
callfunction getname 1
elif TYPE == 198
elif TYPE == 199
elif TYPE == 3584 # last file
else
endif
endfunction
startfunction getname
goto OFFSET
get NAMEL long
set TEST NAMEL
math TEST %= 4
if TEST != 0 # round to next 4byte
math NAMEL /= 4
math NAMEL += 1
math NAMEL *= 4
endif
getDstring FNAME NAMEL
savepos NBIAS
math NBIAS -= OFFSET
math OFFSET += NBIAS
math SIZE -= NBIAS
endfunction
startfunction getType
goto OFFSET
get DUMMY long
get TYPE long
if TYPE == 0x6d783f3c
math OFFSET += 4
set SIZE DUMMY
set EXT ".xml"
elif TYPE == 0x474e5089
math OFFSET += 4
set SIZE DUMMY
set EXT ".png"
endif
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment