Skip to main content

A runtime reflection toolkit for Unity applications, enabling real-time inspection and interaction with classes, methods, and fields and objects.

Project description

unity_helper

unity_helper is a runtime inspection toolkit for Unity applications, designed to expose reflection data including classes, methods, and fields. It allows you to explore and interact with application internals dynamically and in real time.

Features

  • Support for obtaining unity image data
  • Support for obtaining unity class data
  • Support for obtaining unity method data
  • Support for obtaining unity field data
  • Supports IL2CPP scripting backend

Installation

unity_helper requires Windows Python 3.11+ (64-bit) operating environment, you can complete the installation through pip:

pip install -U unity_helper

Examples

import ctypes
from unity_helper import Il2cpp

# Initialize the class
ref = Il2cpp()

# Getting a MonoClass object
time = ref.get_class_from_name('UnityEngine.CoreModule.dll', 'UnityEngine', 'Time')

# Getting MonoClass info
print('Time info:', time.name, time.object, time.type, time.instance)

# Listing method info in a MonoClass
for method in time.list_methods():
    print('Method info:', method.name, method.address, method.methodInfo, method.is_static, method.param_count, method.param_info)


# Getting a MonoMethod object based off of name
set_timeScale = time.find_method('set_timeScale')

# Calling the method
if not set_timeScale.is_static:
    time.instance = 123456789

set_timeScale((ctypes.c_float(5)))


# Calling the method with a ctypes functype
new_set_timeScale = ctypes.WINFUNCTYPE(ctypes.c_void_p, ctypes.c_float)(set_timeScale.address)
new_set_timeScale(5.0)



# Listing field info in a MonoClass
for field in time.list_fields():
    print('Field info:', field.name, field.ptr, field.type, field.is_static)

    if not field.is_static:
        time.instance = 123456789
        print('Value:', field.value)


# Getting a field from name
example_field = time.find_field('example_field')


# Setting a field value in a MonoClass
if not example_field.is_static:
    time.instance = 123456789

example_field.value = 9999


# Getting the main camera and getting a rigidbody
main_cam = ref.get_main_camera()
rigidbody = ref.get_RigidBody(123456789)

# Getting/editing rigidbody info
velocity = rigidbody.velocity
velocity.y = 10
rigidbody.velocity = velocity 

pos = rigidbody.position

print(pos.x, pos.y, pos.z)


# Getting/editing camera info
fov = main_cam.fov
main_cam.fov = fov + 10.0

enabled = main_cam.enabled
main_cam.enabled = not enabled

print(main_cam.name)

# Finding a object based off name
player = ref.find_object('Player')


# Finding a object based off of tag
player = ref.find_object_with_tag('Player')


# Listing images
for image in ref.list_assemblies():
    print(image)


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

More Features

The example above covers some common use cases, but unity_helper also enables:

  • Inspecting and interacting with Scene objects to find and manipulate game entities in real time
  • Accessing and modifying Component objects, including Rigidbodies, Cameras, scripts and more
  • Exploring and updating Transform objects, such as position, rotation, rect and more

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.0.0.tar.gz (14.1 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.0.0-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for unity_helper-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2c38d1cf15168e54174ccc94f8879b530c97fb7847d3dd89d6931379bfb64a71
MD5 c3df01b8b6e3cc19232956f6bf26313c
BLAKE2b-256 d9b50593dadf52704c2d0bcce29d4f68259df192a7eabb655f54ce0dff1d58f9

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for unity_helper-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 81ae1b83890de071d540dfe7627c3880de2cd02fb860e962811a289e1d7982f0
MD5 1fc7969a539739d09fc36aa9a21d10b0
BLAKE2b-256 5399a76ab45f01cd891b8b21e0c9252ad2fecc4603c4c3da618d99a21cb6de78

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