Skip to content
This repository was archived by the owner on Feb 6, 2026. It is now read-only.

Latest commit

 

History

History
89 lines (86 loc) · 3.47 KB

File metadata and controls

89 lines (86 loc) · 3.47 KB

UnityPyTypetreeCodegen

(WIP) Static TypeTree code analysis and code generation for UnityPy

Used in

Usage

Installation

pip install UnityPyTypetreeCodegen

Generating code

UnityPyTypetreeCodegen --json "path_to_typetree_json_dump" --output "generated_module_path"
  • Or dump the TypeTree from ourselves from Unity assemblies (mono dlls)
UnityPyTypetreeCodegen --asm-dir "path/to/Managed/DLLs" --output "generated_module_path"
# or with IL2CPP
UnityPyTypetreeCodegen --il2cpp "path/to/il2cpp.so" --metadata "path/to/global-metadata.dat" --output "generated_module_path"
  • The emitted module will be structured like this
generated
├── __init__.py
└── Live2D
    └── Cubism
        ├── Core
        │   ├── __init__.py
        │   └── Unmanaged
        │       └── __init__.py
        ├── Framework
        │   ├── __init__.py
        │   ├── Expression
        │   │   └── __init__.py
        │   ├── HarmonicMotion
        │   │   └── __init__.py
        │   ├── Json
        │   │   └── __init__.py
        │   ├── LookAt
        │   │   └── __init__.py
        │   ├── Motion
        │   │   └── __init__.py
        │   ├── MotionFade
        │   │   └── __init__.py
        │   ├── MouthMovement
        │   │   └── __init__.py
        │   ├── Physics
        │   │   └── __init__.py
        │   ├── Pose
        │   │   └── __init__.py
        │   ├── Raycasting
        │   │   └── __init__.py
        │   ├── Tasking
        │   │   └── __init__.py
        │   └── UserData
        │       └── __init__.py
        └── Rendering
            ├── __init__.py
            └── Masking
                └── __init__.py

20 directories, 18 files

Using the generated module

Example usage in rla_transport_defines

env = UnityPy.load(...)
from generated import UTTCGen_AsInstance, UTTCGen_GetClass

for reader in filter(lambda x: x.type == ClassIDType.MonoBehaviour, env.objects):
    name = reader.peek_name()
    if name.startswith("TransportDefine"):        
        from generated.Sekai.Streaming import TransportDefine
        # ...or TransportDefine = UTTCGen_GetClass("Sekai.Streaming.TransportDefine")
        # ...or TransportDefine = UTTCGen_GetClass(reader.read(check_read=False))
        instance = UTTCGen_AsInstance(TransportDefine, reader)                
        print(f'"{name}":({instance.validBones}, {instance.validBlendShapes}),')
        # Possibly modify on the instance itself and saving it is also possible
        instance.validBones[0] = "BadBone"
        instance.save()
env.save()