PythonConsole

v1.1.2·Updated 2021-02-17

Adds IronPython-based Console to Unity

About this mod Author’s original text

Unity-Console

Unity-Console is an IronPython-base Console for Unity

  • What it does

The libraries involved will enable opening a console which allows user to run commands for inspecting global state of the Unity application.

It can be used to manipulate the game assets with some research

You can also use it to load Python based mods that run in the background

  • How it works

The basic idea is to run custom code in unity that enables opening a console window that is under the control of this library.

Unity is not thread safe which means its not safe to perform actions on Unity elements from the Console without additional actions. This is easier said than done but I have provided some support via the coroutine library.

The library will allow python code to be run in unity in small pieces this allows python to yield to for Unity to perform actions like redrawing the view and doing other actions that it needs.

  • Directory Structure Overview

r9modman does not respect folders or structure so ignore this when using that tool

\BepInEx\

The root folder managed by BepInEx. Shared by BepInEx and plugins.

\BepInEx\plugins\Unity.Console.BepInEx.dll

The plugin specific for bepinex.dll

\BepInEx\Console\

Folder for most of the plugin. Unity.Console.Dll is hard

coded into the plugin above for launching.

\BepInEx\Console\Lib\

This folder is the location for python based scripts.

  • Installation

Prerequisites:

  • Download BepInEx 5 LTS version

BepInEx_x64_5.4.5.0.zip was tested.

The current versions can be downloaded from here:

More help on BepInEx

  • Unpack BepInEx to game folder so winhttp.dll is in same folder as DSPGAME.exe
  • Test game still loads before adding console

Install:

  • Download the current version of UnityConsole
  • Unpack to game folder. BepInEx folder is already present so extract

to same folder as DSPGAME.exe

  • Edit BepInEx\Console\Console.INI to your liking

Suggested to look at:

[Console]ShowKey=F12 # shortcut to open console

[Console]PersistHistory=0 # whether to save typed commands

[Console]ShowAtStartup=0 # whether to show console at start

[Console]MoveToMonitor=-1 # have console open in another monitor if present

r9modman expects you to use its complicated stuff so this file is elsewhere when using that.

  • Add python mods to BepInEx\Console\Mods\
  • Examples

Console can be opened using ShowKey from the Console.ini

By default, this is F12 to toggle the console on and off

Console can be closed typing ^Z or exit()

> import UnityEngine
> print UnityEngine.Application.unityVersion

'2018.4.12f1'

There is an example mod in \BepInEx\Console\Mods\test

Its not very good and its old but it shows simple IMGUI behavior

  • TODO

I'm sure there can be a lot done to improve some basic scripting libraries.

Examples could be greatly expanded upon.

Fix the issue with console not working correctly after being shutdown

the first time on subsequent reopening.

  • Contact

The code is offered as-is for demonstration purposes.

The author apologizes for not having time to maintain the code but

hopes that it is still useful to other users.

The official homepage:

You can report bugs or other issues.

  • Change log

Version 1.1.2

Correctly packaged version of 1.1.1 which should work with r9modman

Version 1.1.1

Add support for r9modman like datastructures which reformat folder structures

Version 1.1

Initial release

Install & use Install: BepInEx plugin

  1. The archive from playbuff is the mod itself — usually a BepInEx plugin (a .dll or a plugin folder once unzipped).
  2. Recommended: use a community mod manager (such as r2modman) — pick this game, import the mod, and the manager sets up BepInEx and its dependencies for you.
  3. Manual route: install the BepInEx loader in the game folder, then drop the unzipped .dll or plugin folder into BepInEx/plugins/.
  4. Launch the game — the BepInEx console logs every plugin it loads; seeing this mod in the log means it is installed.

Mods with listed dependencies need those installed too, or they will not load. Options are usually changed in-game or in the plugin's config file.

Dependencies

Install these first, or the mod will not work:

xiaoye97-BepInEx

File & checksum

Filename
PythonConsole-1.1.2.zip
File size
7.0 MiB