TheHologram-PythonConsole icon

PythonConsole

Adds IronPython-based Console to Unity

Last updated 3 years ago
Total downloads 2747
Total rating 1 
Categories
Dependency string TheHologram-PythonConsole-1.1.2
Dependants 1 other package depends on this package

This mod requires the following mods to function

xiaoye97-BepInEx-5.4.5 icon
xiaoye97-BepInEx

BepInEx5.4.5 mod plugin framework, Mod框架

Preferred version: 5.4.5

README

#Unity-Console

Unity-Console is an IronPython-base Console for Unity


  1. 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

  1. 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.

  1. 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.

  1. Installation

Prerequisites:
  1. Download BepInEx 5 LTS version
     
     BepInEx_x64_5.4.5.0.zip was tested.
       https://github.com/BepInEx/BepInEx/releases/download/v5.4.5/BepInEx_x64_5.4.5.0.zip
       
     The current versions can be downloaded from here:
      https://github.com/BepInEx/BepInEx/releases
      
     More help on BepInEx
      https://github.com/BepInEx/BepInEx/wiki/Installation 
      
  2. Unpack BepInEx to game folder so winhttp.dll is in same folder as DSPGAME.exe
           
  3. Test game still loads before adding console

Install:
  1. Download the current version of UnityConsole
    
  2. Unpack to game folder.  BepInEx folder is already present so extract
     to same folder as DSPGAME.exe
  
  3. 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.
  
  4. Add python mods to BepInEx\Console\Mods\ 

  1. 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<return> or exit()<return>

>>> 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

  1. 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.

  1. 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:
  https://github.com/TheHologram/unity-console
  https://github.com/TheHologram/DSP_Mods

You can report bugs or other issues at nexus.
    https://www.nexusmods.com/dysonsphereprogram/mods/10

  1. 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