cocos3dx web反编译第一篇
将其脚本分类输出到code文件夹中
import os
import re
# 定义文件夹路径
game_code_folder = "game_code"
output_folder = "code"
# 确保输出文件夹存在
os.makedirs(output_folder, exist_ok=True)
# 定义正则表达式,用于匹配完整的 System.register 代码块
pattern = re.compile(
r'System\.register\("chunks:///_virtual/([^"]+)"\s*,\s*\[.*?\],\s*(\(.*?\))\);',
re.DOTALL
)
# 遍历 game_code 文件夹中的所有 .js 文件
for root, dirs, files in os.walk(game_code_folder):
for file in files:
if file.endswith(".js"):
file_path = os.path.join(root, file)
print(f"Processing file: {file_path}")
# 读取文件内容
with open(file_path, "r", encoding="utf-8") as f:
content = f.read()
# 查找所有匹配的 System.register 代码块
matches = pattern.findall(content)
for match in matches:
module_name = match[0] # 模块名称,例如 "AnimPoker.ts"
module_code = match[1] # 模块代码内容
# 创建目标文件路径
target_file_path = os.path.join(output_folder, module_name)
# 直接将完整的 System.register 代码块写入目标文件
with open(target_file_path, "w", encoding="utf-8") as target_file:
target_file.write(f'System.register("chunks:///_virtual/{module_name}", [], {module_code});')
print(f"Created file: {target_file_path}")
print("Processing complete.")
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END








暂无评论内容