Spaces:
webzepetoku
/
Sleeping

webzepetoku commited on
Commit
c5ce366
·
verified ·
1 Parent(s): ecde384

Create extractor.py

Browse files
Files changed (1) hide show
  1. extractor.py +39 -0
extractor.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import UnityPy
2
+ import sys
3
+
4
+ if len(sys.argv) < 3:
5
+ sys.exit(1)
6
+
7
+ mode = sys.argv[1]
8
+ bundle_path = sys.argv[2]
9
+
10
+ if mode == "extract":
11
+ mesh_out = sys.argv[3]
12
+ tex_out = sys.argv[4]
13
+ env = UnityPy.load(bundle_path)
14
+ m_done = False
15
+ t_done = False
16
+
17
+ for obj in env.objects:
18
+ if obj.type.name == "Mesh" and not m_done:
19
+ with open(mesh_out, "wb") as f:
20
+ f.write(obj.get_raw_data())
21
+ m_done = True
22
+ elif obj.type.name == "Texture2D" and not t_done:
23
+ with open(tex_out, "wb") as f:
24
+ f.write(obj.get_raw_data())
25
+ t_done = True
26
+ print("EXTRACTION_DONE")
27
+
28
+ elif mode == "find_id":
29
+ env = UnityPy.load(bundle_path)
30
+ m_id = "NONE"
31
+ t_id = "NONE"
32
+
33
+ for obj in env.objects:
34
+ if obj.type.name == "Mesh" and m_id == "NONE":
35
+ m_id = str(obj.path_id)
36
+ elif obj.type.name == "Texture2D" and t_id == "NONE":
37
+ t_id = str(obj.path_id)
38
+
39
+ print(f"IDS:{m_id},{t_id}")