Skip to main content

Runtime inspection toolkit for Unity IL2CPP applications — explore classes, methods, fields, and live objects in real time.

Project description

unity_helper

Runtime inspection toolkit for Unity IL2CPP applications — explore classes, methods, fields, and live objects in real time.

Python Platform License


✨ Overview

unity_helper is a Python toolkit for runtime inspection of Unity applications using the IL2CPP scripting backend. It provides reflection-like capabilities, allowing you to dynamically explore and interact with internal game structures directly from Python.


🚀 Features

  • Inspect Unity assemblies (images)
  • Explore classes, methods, and fields
  • Call methods dynamically at runtime
  • Read and modify field values
  • Interact with live Unity objects (Camera, Rigidbody, etc.)
  • Designed specifically for IL2CPP environments

⚡ Quick Start

from unity_helper import Il2cpp

ref = Il2cpp()

# Get a Unity class
time = ref.get_class_from_name(
    'UnityEngine.CoreModule.dll',
    'UnityEngine.Time'
)

print(time.name)

📦 Installation

pip install -U unity_helper

🧰 Requirements

  • Windows (64-bit)
  • Python 3.11+
  • Target application using Unity IL2CPP

🧪 Examples

🔹 Class & Method Inspection

time = ref.get_class_from_name(
    'UnityEngine.CoreModule.dll',
    'UnityEngine.Time'
)

print('Time info:', time.cls, time.name, time.object, time.type, time.instance)

for method in time.list_methods():
    print(
        'Method info:',
        method.name,
        method.address,
        method.methodInfo,
        method.is_static,
        method.param_count
    )

🔹 Calling Methods

import ctypes

set_timeScale = time.find_method('set_timeScale')
set_timeScale = time.method.set_timeScale # Getting a method the lazy way

if not set_timeScale.is_static:
    time.instance = 123456789

set_timeScale(ctypes.c_float(5)) # Invoke set_timeScale with an explicit native float type
set_timeScale_m(5.0) # Invoke set_timeScale with automatic type conversion

Using ctypes directly (most consistent):

new_set_timeScale = ctypes.WINFUNCTYPE(
    ctypes.c_void_p,
    ctypes.c_float
)(set_timeScale.address)

new_set_timeScale(5.0)

🔹 Field Access

for field in time.list_fields():
    print('Field:', field.name, field.type, field.is_static)

example_field = time.find_field('example_field')
example_field = time.field.example_field # Getting a field the lazy way


if not example_field.is_static:
    time.instance = 123456789

example_field.value = 9999

🔹 Working with Unity Objects

main_cam = ref.get_mainCamera()
rigidbody = unity_helper.objects.Rigidbody(123456789)

Rigidbody

velocity = rigidbody.velocity
velocity.y = 10
rigidbody.velocity = velocity

pos = rigidbody.position
print(pos.x, pos.y, pos.z)

Camera

fov = main_cam.fov
main_cam.fov = fov + 10.0

main_cam.enabled = not main_cam.enabled
print(main_cam.name)

🔹 Finding Objects

player = ref.find_object('Player')
player = ref.find_object_with_tag('Player')

🔹 Assemblies & Classes

for image in ref.list_assemblies():
    print(image)

for clazz in ref.list_classes_in_image('Assembly-CSharp.dll'):
    print(clazz.name)

🎯 Common Use Cases

  • Runtime debugging of Unity applications
  • Reverse engineering IL2CPP builds
  • Building tooling and automation scripts
  • Inspecting and modifying live game state
  • Creating game mods

⚠️ Important Notes

  • This is a Python script that must be executed within the game's process.
  • It does not work as a standalone script and cannot interact with external processes.
  • Running it outside of the game environment will not work.
  • Directly calling a MonoMethod can lead to inconsistencies due to the vast number of underlying engine data types. For best results, dynamically create a WINFUNCTYPE or CFUNCTYPE wrapper and invoke it that way.

🔴 Known issues

  • None! All known bugs have been squashed. If you run into any unexpected behavior or crashes, please feel free to open an Issue on GitHub.

📝 Future Roadmap / TODO

  • Eliminate the pylocalmem dependency by reimplementing all required functions in memory.py using ReadProcessMemory, ensuring crash safety.
  • Add obfuscation detection and implement basic name de-obfuscation. (Experimental / Tentative)

📄 License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unity_helper-1.3.6.tar.gz (27.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

unity_helper-1.3.6-py3-none-any.whl (29.1 kB view details)

Uploaded Python 3

File details

Details for the file unity_helper-1.3.6.tar.gz.

File metadata

  • Download URL: unity_helper-1.3.6.tar.gz
  • Upload date:
  • Size: 27.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for unity_helper-1.3.6.tar.gz
Algorithm Hash digest
SHA256 5d37e3031681c524fbf9b68d8876f2501b85365018c8cbe53076d0b7e18a609e
MD5 36e915d5d93af860b1c590cb51ac8fd9
BLAKE2b-256 da30308f923b33bc23e8dd774f8c4ed6431d0ded529d0ba4bd8f8a0a86190371

See more details on using hashes here.

File details

Details for the file unity_helper-1.3.6-py3-none-any.whl.

File metadata

  • Download URL: unity_helper-1.3.6-py3-none-any.whl
  • Upload date:
  • Size: 29.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for unity_helper-1.3.6-py3-none-any.whl
Algorithm Hash digest
SHA256 2abb9e899a064d064fca4adb33ab60c115623ff56748b6366b84f470fb2e8796
MD5 3f74d3ec9926dcd1725b30b7cf955e11
BLAKE2b-256 5f7c1ed4a7dba8f7fc52e1f671d6f8a59ccab2d4f413efef62627a94af720845

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page