PythonConsole

版本 v1.1.2·更新於 2021-02-17

Adds IronPython-based Console to Unity

模組介紹 作者原文

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

安裝與使用 安裝:BepInEx 外掛

  1. 本站下載的壓縮包就是模組本體,通常是 BepInEx 外掛(解壓後得到 .dll 或外掛資料夾)。
  2. 建議流程:用社群模組管理器(如 r2modman)選中本遊戲後匯入該模組,管理器會自動裝好 BepInEx 前置並處理依賴。
  3. 手動流程:先在遊戲目錄裝好 BepInEx 載入器,再把解壓出的 .dll 或外掛資料夾放進 BepInEx/plugins/。
  4. 啟動遊戲,BepInEx 控制台會列印載入日誌;確認這個模組出現在日誌裡即為安裝成功。

帶「前置依賴」的模組需要一併安裝,否則不會載入。功能開關通常在遊戲內或外掛自帶的設定檔裡調整。

前置依賴

下面這些內容需要先安裝,否則該模組不會生效:

xiaoye97-BepInEx

檔案與校驗

檔案名稱
PythonConsole-1.1.2.zip
檔案大小
7.0 MiB