mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-23 08:53:05 +08:00
Compare commits
57 Commits
Author | SHA1 | Date | |
---|---|---|---|
7a59f9a2a1 | |||
9b42eef1b9 | |||
830000b019 | |||
34910ab273 | |||
86b036095e | |||
b57e5be2e6 | |||
2d8ae45814 | |||
66dc262a68 | |||
4342901206 | |||
58b7c72a5c | |||
623dc7b7be | |||
e6f4939cc9 | |||
7a539ba78b | |||
0d10f94eb5 | |||
91671bf243 | |||
a72877befb | |||
16335c1bc4 | |||
8fab9e6268 | |||
fdd9039cca | |||
dcca980635 | |||
bfcab8248e | |||
97c20144f1 | |||
aaab10a0a0 | |||
b42a8dbe6a | |||
d7008db22e | |||
8c1913fe80 | |||
8d8c9ac7c9 | |||
f35beeaf58 | |||
d150ff3455 | |||
c4fa0d6bcd | |||
a5f56cf5a3 | |||
8c822b2ee9 | |||
4681b7e192 | |||
97093733d8 | |||
615f77979f | |||
ba3cf970d9 | |||
b2fb571b18 | |||
67ce6f946a | |||
1b82ccb49f | |||
480eb5afd5 | |||
88ea2a09c9 | |||
a678aa4d78 | |||
eaf478e314 | |||
d391968b32 | |||
70349ad7c7 | |||
78f2d1070f | |||
51307563ab | |||
185d1aaa0f | |||
3d6e8fcbf8 | |||
1daf4fade4 | |||
d92fb3f83f | |||
fe24b68fe2 | |||
6bf92b9a96 | |||
9f1cab019d | |||
a131404ac7 | |||
773900d749 | |||
342fc6bdb8 |
113
.github/workflows/dotnet.yml
vendored
Normal file
113
.github/workflows/dotnet.yml
vendored
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
name: Build UnityExplorer
|
||||||
|
|
||||||
|
# Controls when the action will run.
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
# Allows you to run this workflow manually from the Actions tab
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: windows-latest
|
||||||
|
if: "!contains(github.event.head_commit.message, '-noci')"
|
||||||
|
|
||||||
|
steps:
|
||||||
|
# Checkout latest with submodules
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
# Setup tools
|
||||||
|
- name: Setup msbuild
|
||||||
|
uses: microsoft/setup-msbuild@v1
|
||||||
|
|
||||||
|
- name: Setup nuget
|
||||||
|
uses: nuget/setup-nuget@v1
|
||||||
|
with:
|
||||||
|
nuget-api-key: ${{ secrets.NuGetAPIKey }}
|
||||||
|
nuget-version: '5.x'
|
||||||
|
|
||||||
|
# Build Il2CppAssemblyUnhollower
|
||||||
|
- run: msbuild lib\Il2CppAssemblyUnhollower\UnhollowerBaseLib\UnhollowerBaseLib.csproj -t:Restore -t:Rebuild -p:Platform="AnyCPU" -p:Configuration=Release
|
||||||
|
|
||||||
|
# Build mcs
|
||||||
|
- run: nuget restore lib\mcs-unity\mcs.sln
|
||||||
|
- run: msbuild lib\mcs-unity\mcs\mcs.csproj -t:Restore -t:Rebuild -p:Platform="AnyCPU" -p:Configuration=Release
|
||||||
|
|
||||||
|
# Build UnityExplorer releases, and upload artifacts
|
||||||
|
|
||||||
|
- run: nuget restore src\UnityExplorer.sln
|
||||||
|
|
||||||
|
# BepInEx Il2Cpp
|
||||||
|
- run: msbuild src\UnityExplorer.csproj -t:Rebuild -p:Platform="AnyCPU" -p:Configuration=Release_BIE_Cpp
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: UnityExplorer.BepInEx.Il2Cpp
|
||||||
|
path: ./Release/UnityExplorer.BepInEx.Il2Cpp/*
|
||||||
|
|
||||||
|
# BepInEx 5 Mono
|
||||||
|
- run: msbuild src\UnityExplorer.csproj -t:Rebuild -p:Platform="AnyCPU" -p:Configuration=Release_BIE5_Mono
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: UnityExplorer.BepInEx5.Mono
|
||||||
|
path: ./Release/UnityExplorer.BepInEx5.Mono/*
|
||||||
|
|
||||||
|
# BepInEx 6 Mono
|
||||||
|
- run: msbuild src\UnityExplorer.csproj -t:Rebuild -p:Platform="AnyCPU" -p:Configuration=Release_BIE6_Mono
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: UnityExplorer.BepInEx6.Mono
|
||||||
|
path: ./Release/UnityExplorer.BepInEx6.Mono/*
|
||||||
|
|
||||||
|
# MelonLoader Il2Cpp
|
||||||
|
- run: msbuild src\UnityExplorer.csproj -t:Rebuild -p:Platform="AnyCPU" -p:Configuration=Release_ML_Cpp
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: UnityExplorer.MelonLoader.Il2Cpp
|
||||||
|
path: ./Release/UnityExplorer.MelonLoader.Il2Cpp/*
|
||||||
|
|
||||||
|
# MelonLoader Mono
|
||||||
|
- run: msbuild src\UnityExplorer.csproj -t:Rebuild -p:Platform="AnyCPU" -p:Configuration=Release_ML_Mono
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: UnityExplorer.MelonLoader.Mono
|
||||||
|
path: ./Release/UnityExplorer.MelonLoader.Mono/*
|
||||||
|
|
||||||
|
# MelonLoader 0.3.0 Il2Cpp
|
||||||
|
- run: msbuild src\UnityExplorer.csproj -t:Rebuild -p:Platform="AnyCPU" -p:Configuration=Release_MLLegacy_Cpp
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: UnityExplorer.MelonLoader_Legacy.Il2Cpp
|
||||||
|
path: ./Release/UnityExplorer.MelonLoader_Legacy.Il2Cpp/*
|
||||||
|
|
||||||
|
# MelonLoader 0.3.0 Mono
|
||||||
|
- run: msbuild src\UnityExplorer.csproj -t:Rebuild -p:Platform="AnyCPU" -p:Configuration=Release_MLLegacy_Mono
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: UnityExplorer.MelonLoader_Legacy.Mono
|
||||||
|
path: ./Release/UnityExplorer.MelonLoader_Legacy.Mono/*
|
||||||
|
|
||||||
|
# Standalone Il2Cpp
|
||||||
|
- run: msbuild src\UnityExplorer.csproj -t:Rebuild -p:Platform="AnyCPU" -p:Configuration=Release_STANDALONE_Cpp
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: UnityExplorer.Standalone.Il2Cpp
|
||||||
|
path: ./Release/UnityExplorer.Standalone.Il2Cpp/*
|
||||||
|
|
||||||
|
# Standalone Mono
|
||||||
|
- run: msbuild src\UnityExplorer.csproj -t:Rebuild -p:Platform="AnyCPU" -p:Configuration=Release_STANDALONE_Mono
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: UnityExplorer.Standalone.Mono
|
||||||
|
path: ./Release/UnityExplorer.Standalone.Mono/*
|
||||||
|
|
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,9 +1,6 @@
|
|||||||
[submodule "lib/Il2CppAssemblyUnhollower"]
|
[submodule "lib/Il2CppAssemblyUnhollower"]
|
||||||
path = lib/Il2CppAssemblyUnhollower
|
path = lib/Il2CppAssemblyUnhollower
|
||||||
url = https://github.com/knah/Il2CppAssemblyUnhollower
|
url = https://github.com/knah/Il2CppAssemblyUnhollower
|
||||||
[submodule "lib/HarmonyX"]
|
|
||||||
path = lib/HarmonyX
|
|
||||||
url = https://github.com/BepInEx/HarmonyX
|
|
||||||
[submodule "lib/mcs-unity"]
|
[submodule "lib/mcs-unity"]
|
||||||
path = lib/mcs-unity
|
path = lib/mcs-unity
|
||||||
url = https://github.com/sinai-dev/mcs-unity
|
url = https://github.com/sinai-dev/mcs-unity
|
||||||
|
112
README.md
112
README.md
@ -3,44 +3,48 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
An in-game explorer and a suite of debugging tools for <a href="https://docs.unity3d.com/Manual/IL2CPP.html">IL2CPP</a> and <b>Mono</b> Unity games, to aid with modding development.
|
🔍 An in-game UI for exploring, debugging and modifying Unity games.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
Supports most Unity games from versions 5.2 to 2020+.
|
✔️ Supports most Unity versions from 5.2 to 2020+ (IL2CPP and Mono).
|
||||||
|
</p>
|
||||||
|
<p align="center">
|
||||||
|
☕ Enjoy this tool? Consider supporting me on <a href="https://ko-fi.com/sinaidev">ko-fi</a>!
|
||||||
|
</p>
|
||||||
|
<p align="center">
|
||||||
|
⚡ UnityExplorer is on <a href="https://thunderstore.io/package/sinai-dev/UnityExplorer/">Thunderstore</a>! (and as <a href="https://gtfo.thunderstore.io/package/sinai-dev/UnityExplorer_IL2CPP/">IL2CPP</a>)
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
## Releases [](../../releases/latest) [](../../releases) [](../../releases/latest)
|
# Releases [](../../releases)
|
||||||
|
|
||||||
| Mod Loader | IL2CPP | Mono |
|
[](../../releases/latest) [](https://github.com/sinai-dev/UnityExplorer/actions) [](../../releases/latest)
|
||||||
| ----------- | ------ | ---- |
|
|
||||||
| [BepInEx](https://github.com/BepInEx/BepInEx) 6.X | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.BepInEx.Il2Cpp.zip) | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.BepInEx6.Mono.zip) |
|
|
||||||
| [BepInEx](https://github.com/BepInEx/BepInEx) 5.X | ✖️ n/a | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.BepInEx5.Mono.zip) |
|
|
||||||
| [MelonLoader](https://github.com/HerpDerpinstine/MelonLoader) 0.3.1 | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.MelonLoader.Il2Cpp.zip) | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.MelonLoader.Mono.zip) |
|
|
||||||
| [MelonLoader](https://github.com/HerpDerpinstine/MelonLoader) 0.3.0 | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.MelonLoader_Legacy.Il2Cpp.zip) | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.MelonLoader_Legacy.Mono.zip) |
|
|
||||||
| Standalone | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.Standalone.Il2Cpp.zip) | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.Standalone.Mono.zip) |
|
|
||||||
|
|
||||||
### Known issues
|
## BepInEx
|
||||||
* Any `MissingMethodException` or `NotSupportedException`: please report the issue and provide a copy of your mod loader log and/or Unity log.
|
|
||||||
* In IL2CPP, some IEnumerable and IDictionary types may fail enumeration. Waiting for the Unhollower rewrite to address this any further.
|
|
||||||
* The C# Console's completions have some minor issues such as not suggestion global classes which have no namespace, and erronously suggesting classes from using directives when they shouldn't be suggested. These are issues with mcs itself which I am looking into.
|
|
||||||
|
|
||||||
## How to install
|
| Release | IL2CPP | Mono |
|
||||||
|
| ------- | ------ | ---- |
|
||||||
|
| BIE 6.X | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.BepInEx.Il2Cpp.zip) | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.BepInEx6.Mono.zip) |
|
||||||
|
| BIE 5.X | ✖️ n/a | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.BepInEx5.Mono.zip) |
|
||||||
|
|
||||||
### BepInEx
|
1. Take the `UnityExplorer.BIE.[version].dll` file and put it in `BepInEx\plugins\`
|
||||||
|
2. In IL2CPP, you will need to download the [Unity libs](https://github.com/LavaGang/Unity-Runtime-Libraries) for the game's Unity version, create a folder `BepInEx\unity-libs\`, then extract the Unity libs into this folder.
|
||||||
|
|
||||||
1. Install [BepInEx](https://github.com/BepInEx/BepInEx) for your game. IL2CPP currently requires a [Bleeding Edge](https://builds.bepis.io/projects/bepinex_be) release.
|
<i>Note: BepInEx 6 is obtainable via [BepisBuilds](https://builds.bepis.io/projects/bepinex_be)</i>
|
||||||
2. Download the UnityExplorer release for BepInEx IL2CPP or Mono above.
|
|
||||||
3. Take the `UnityExplorer.BIE.___.dll` file and put it in `[GameFolder]\BepInEx\plugins\`
|
|
||||||
4. In IL2CPP, you will need to download the [Unity libs](https://github.com/LavaGang/Unity-Runtime-Libraries) for the game's Unity version and put them in the `BepInEx\unity-libs\` folder.
|
|
||||||
|
|
||||||
### MelonLoader
|
## MelonLoader
|
||||||
|
|
||||||
1. Install [MelonLoader](https://github.com/HerpDerpinstine/MelonLoader) 0.3.1+ for your game (or use `MelonLoader_Legacy` for `0.3.0`). This version can currently be obtained from [here](https://github.com/LavaGang/MelonLoader/actions).
|
| Release | IL2CPP | Mono |
|
||||||
2. Download the UnityExplorer release for MelonLoader IL2CPP or Mono above.
|
| ------- | ------ | ---- |
|
||||||
3. Take the `UnityExplorer.ML.___.dll` file and put it in the `[GameFolder]\Mods\` folder.
|
| ML 0.4.0 | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.MelonLoader.Il2Cpp.zip) | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.MelonLoader.Mono.zip) |
|
||||||
|
| ML 0.3.0 | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.MelonLoader_Legacy.Il2Cpp.zip) | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.MelonLoader_Legacy.Mono.zip) |
|
||||||
|
|
||||||
### Standalone
|
1. Take the `UnityExplorer.ML.[version].dll` file and put it in the `Mods\` folder created by MelonLoader.
|
||||||
|
|
||||||
|
## Standalone
|
||||||
|
|
||||||
|
| IL2CPP | Mono |
|
||||||
|
| ------ | ---- |
|
||||||
|
| ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.Standalone.Il2Cpp.zip) | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.Standalone.Mono.zip) |
|
||||||
|
|
||||||
The standalone release can be used with any injector or loader of your choice, but it requires you to load the dependencies manually: HarmonyX, and the IL2CPP version also requires that you set up an [Il2CppAssemblyUnhollower runtime](https://github.com/knah/Il2CppAssemblyUnhollower#required-external-setup).
|
The standalone release can be used with any injector or loader of your choice, but it requires you to load the dependencies manually: HarmonyX, and the IL2CPP version also requires that you set up an [Il2CppAssemblyUnhollower runtime](https://github.com/knah/Il2CppAssemblyUnhollower#required-external-setup).
|
||||||
|
|
||||||
@ -49,7 +53,12 @@ The standalone release can be used with any injector or loader of your choice, b
|
|||||||
3. Create an instance of Unity Explorer with `UnityExplorer.ExplorerStandalone.CreateInstance();`
|
3. Create an instance of Unity Explorer with `UnityExplorer.ExplorerStandalone.CreateInstance();`
|
||||||
4. Optionally subscribe to the `ExplorerStandalone.OnLog` event to handle logging if you wish
|
4. Optionally subscribe to the `ExplorerStandalone.OnLog` event to handle logging if you wish
|
||||||
|
|
||||||
## Features
|
# Known issues
|
||||||
|
* Any `MissingMethodException` or `NotSupportedException`: please report the issue and provide a copy of your mod loader log and/or Unity log.
|
||||||
|
* In IL2CPP, some IEnumerable and IDictionary types may fail enumeration. Waiting for the Unhollower rewrite to address this any further.
|
||||||
|
* The C# Console's completions have some minor issues such as not suggestion global classes which have no namespace, and erronously suggesting classes from using directives when they shouldn't be suggested. These are issues with mcs itself which I am looking into.
|
||||||
|
|
||||||
|
# Features
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://raw.githubusercontent.com/sinai-dev/UnityExplorer/master/img/preview.png">
|
<a href="https://raw.githubusercontent.com/sinai-dev/UnityExplorer/master/img/preview.png">
|
||||||
@ -59,46 +68,61 @@ The standalone release can be used with any injector or loader of your choice, b
|
|||||||
|
|
||||||
### Object Explorer
|
### Object Explorer
|
||||||
|
|
||||||
* Use the <b>Scene Explorer</b> tab to traverse the active scenes, as well as the DontDestroyOnLoad scene and the HideAndDontSave "scene" (assets and hidden objects).
|
* Use the <b>Scene Explorer</b> tab to traverse the active scenes, as well as the DontDestroyOnLoad and HideAndDontSave objects.
|
||||||
|
* The "HideAndDontSave" scene contains objects with that flag, as well as Assets and Resources which are not in any scene but behave the same way.
|
||||||
|
* You can use the Scene Loader to easily load any of the scenes in the build (may not work for Unity 5.X games)
|
||||||
* Use the <b>Object Search</b> tab to search for Unity objects (including GameObjects, Components, etc), C# Singletons or Static Classes.
|
* Use the <b>Object Search</b> tab to search for Unity objects (including GameObjects, Components, etc), C# Singletons or Static Classes.
|
||||||
|
* Use the UnityObject search to look for any objects which derive from `UnityEngine.Object`, with optional filters
|
||||||
|
* The singleton search will look for any classes with a typical "Instance" field, and check it for a current value. This may cause unexpected behaviour in some IL2CPP games as we cannot distinguish between true properties and field-properties, so some property accessors will be invoked.
|
||||||
|
|
||||||
### Inspector
|
### Inspector
|
||||||
|
|
||||||
The inspector is used to see detailed information on GameObjects (GameObject Inspector), C# objects (Reflection Inspector) and C# classes (Static Inspector).
|
The inspector is used to see detailed information on objects of any type and manipulate their values, as well as to inspect C# Classes with static reflection.
|
||||||
|
|
||||||
* In the GameObject Inspector, you can edit any of the input fields in the inspector (excluding readonly fields) and press <b>Enter</b> to apply your changes. You can also do this to the GameObject path as a way to change the GameObject's parent. Press the <b>Escape</b> key to cancel your edits.
|
* The <b>GameObject Inspector</b> (tab prefix `[G]`) is used to inspect a `GameObject`, and to see and manipulate its Transform and Components.
|
||||||
* In the Reflection Inspectors, automatic updating is not enabled by default, and you must press Apply for any changes you make to take effect.
|
* You can edit any of the input fields in the inspector (excluding readonly fields) and press <b>Enter</b> to apply your changes. You can also do this to the GameObject path as a way to change the GameObject's parent. Press the <b>Escape</b> key to cancel your edits.
|
||||||
|
* <i>note: When inspecting a GameObject with a Canvas, the transform controls may be overridden by the RectTransform anchors.</i>
|
||||||
|
* The <b>Reflection Inspectors</b> (tab prefix `[R]` and `[S]`) are used for everything else
|
||||||
|
* Automatic updating is not enabled by default, and you must press Apply for any changes you make to take effect.
|
||||||
|
* Press the `▼` button to expand certain values such as strings, enums, lists, dictionaries, some structs, etc
|
||||||
|
* Use the filters at the top to quickly find the members you are looking for
|
||||||
|
* For `Texture2D` objects, there is a `View Texture` button at the top of the inspector which lets you view it and save it as a PNG file. Currently there are no other similar helpers yet, but I may add more at some point for Mesh, Sprite, Material, etc
|
||||||
|
|
||||||
### C# Console
|
### C# Console
|
||||||
|
|
||||||
The C# Console uses the `Mono.CSharp.Evaluator` to define temporary classes or run immediate REPL code.
|
* The C# Console uses the `Mono.CSharp.Evaluator` to define temporary classes or run immediate REPL code.
|
||||||
|
* You can execute a script automatically on startup by naming it `startup.cs` and placing it in the `UnityExplorer\Scripts\` folder (this folder will be created where you placed the DLL file).
|
||||||
See the "Help" dropdown in the C# console menu for more detailed information.
|
* See the "Help" dropdown in the C# console menu for more detailed information.
|
||||||
|
|
||||||
### Mouse-Inspect
|
### Mouse-Inspect
|
||||||
|
|
||||||
The "Mouse Inspect" dropdown on the main UnityExplorer navbar allows you to inspect objects under the mouse.
|
* The "Mouse Inspect" dropdown on the main UnityExplorer navbar allows you to inspect objects under the mouse.
|
||||||
|
|
||||||
* <b>World</b>: uses Physics.Raycast to look for Colliders
|
* <b>World</b>: uses Physics.Raycast to look for Colliders
|
||||||
* <b>UI</b>: uses GraphicRaycasters to find UI objects
|
* <b>UI</b>: uses GraphicRaycasters to find UI objects
|
||||||
|
|
||||||
### Settings
|
### Settings
|
||||||
|
|
||||||
You can change the settings via the "Options" page of the main menu, or directly from the config file.
|
* You can change the settings via the "Options" tab of the menu, or directly from the config file.
|
||||||
|
|
||||||
Depending on the release you are using, the config file will be found at:
|
|
||||||
* BepInEx: `BepInEx\config\com.sinai.unityexplorer.cfg`
|
* BepInEx: `BepInEx\config\com.sinai.unityexplorer.cfg`
|
||||||
* MelonLoader: `UserData\MelonPreferences.cfg`
|
* MelonLoader: `UserData\MelonPreferences.cfg`
|
||||||
* Standalone `{DLL_location}\UnityExplorer\config.ini`
|
* Standalone `{DLL_location}\UnityExplorer\config.ini`
|
||||||
|
|
||||||
## Building
|
# Building
|
||||||
|
|
||||||
|
If you fork the repository on GitHub you can build using the [dotnet workflow](https://github.com/sinai-dev/UnityExplorer/blob/master/.github/workflows/dotnet.yml):
|
||||||
|
|
||||||
|
0. Click on the Actions tab and enable workflows in your repository
|
||||||
|
1. Click on the "Build UnityExplorer" workflow, then click "Run Workflow" and run it manually, or make a new commit to trigger the workflow.
|
||||||
|
2. Take the artifact from the completed run.
|
||||||
|
|
||||||
|
For Visual Studio:
|
||||||
|
|
||||||
0. Clone the repository and run `git submodule update --init --recursive` to get the submodules.
|
0. Clone the repository and run `git submodule update --init --recursive` to get the submodules.
|
||||||
1. Open the `src\UnityExplorer.sln` project in Visual Studio.
|
1. Open the `src\UnityExplorer.sln` project.
|
||||||
2. Build `Harmony`, `mcs`, and if IL2CPP `UnhollowerBaseLib` as well.
|
2. Build `mcs` (Release/AnyCPU, you may need to run `nuget restore mcs.sln`), and if using IL2CPP then build `Il2CppAssemblyUnhollower` (Release/AnyCPU) as well.
|
||||||
3. Build the UnityExplorer release(s) you want to use, either by selecting the config as the Active Config, or batch-building. If ILRepack encounters an error on your first build, try changing the active config to a different one, then back again.
|
3. Build the UnityExplorer release(s) you want to use, either by selecting the config as the Active Config, or batch-building.
|
||||||
|
|
||||||
## Acknowledgments
|
# Acknowledgments
|
||||||
|
|
||||||
* [ManlyMarco](https://github.com/ManlyMarco) for [Runtime Unity Editor](https://github.com/ManlyMarco/RuntimeUnityEditor) \[[license](THIRDPARTY_LICENSES.md#runtimeunityeditor-license)\], the ScriptEvaluator from RUE's REPL console was used as the base for UnityExplorer's C# console.
|
* [ManlyMarco](https://github.com/ManlyMarco) for [Runtime Unity Editor](https://github.com/ManlyMarco/RuntimeUnityEditor) \[[license](THIRDPARTY_LICENSES.md#runtimeunityeditor-license)\], the ScriptEvaluator from RUE's REPL console was used as the base for UnityExplorer's C# console.
|
||||||
* [denikson](https://github.com/denikson) (aka Horse) for [mcs-unity](https://github.com/denikson/mcs-unity) \[no license\], used as the `Mono.CSharp` reference for the C# Console.
|
* [denikson](https://github.com/denikson) (aka Horse) for [mcs-unity](https://github.com/denikson/mcs-unity) \[no license\], used as the `Mono.CSharp` reference for the C# Console.
|
||||||
|
Submodule lib/HarmonyX deleted from 64462b3e31
@ -87,9 +87,6 @@ namespace UnityExplorer.Core.Config
|
|||||||
foreach (var entry in ConfigManager.InternalConfigs)
|
foreach (var entry in ConfigManager.InternalConfigs)
|
||||||
sec.AddKey(entry.Key, entry.Value.BoxedValue.ToString());
|
sec.AddKey(entry.Key, entry.Value.BoxedValue.ToString());
|
||||||
|
|
||||||
if (!Directory.Exists(ExplorerCore.Loader.ConfigFolder))
|
|
||||||
Directory.CreateDirectory(ExplorerCore.Loader.ConfigFolder);
|
|
||||||
|
|
||||||
File.WriteAllText(INI_PATH, data.ToString());
|
File.WriteAllText(INI_PATH, data.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
using UnityExplorer.Core.Input;
|
|
||||||
using BF = System.Reflection.BindingFlags;
|
|
||||||
using UnityExplorer.Core.Config;
|
|
||||||
using UnityExplorer.Core;
|
using UnityExplorer.Core;
|
||||||
|
using UnityExplorer.Core.Config;
|
||||||
|
using UnityExplorer.Core.Input;
|
||||||
using UnityExplorer.UI;
|
using UnityExplorer.UI;
|
||||||
using System.Collections;
|
using BF = System.Reflection.BindingFlags;
|
||||||
|
|
||||||
|
|
||||||
namespace UnityExplorer.Core.Input
|
namespace UnityExplorer.Core.Input
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using UnityEngine;
|
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
|
|
||||||
namespace UnityExplorer.Core.Input
|
namespace UnityExplorer.Core.Input
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
using UnityExplorer.UI;
|
using UnityExplorer.UI;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace UnityExplorer.Core.Input
|
namespace UnityExplorer.Core.Input
|
||||||
{
|
{
|
||||||
|
@ -99,8 +99,10 @@ namespace UnityExplorer
|
|||||||
|
|
||||||
public static Exception GetInnerMostException(this Exception e)
|
public static Exception GetInnerMostException(this Exception e)
|
||||||
{
|
{
|
||||||
while (e.InnerException != null)
|
while (e != null)
|
||||||
{
|
{
|
||||||
|
if (e.InnerException == null)
|
||||||
|
break;
|
||||||
#if CPP
|
#if CPP
|
||||||
if (e.InnerException is System.Runtime.CompilerServices.RuntimeWrappedException)
|
if (e.InnerException is System.Runtime.CompilerServices.RuntimeWrappedException)
|
||||||
break;
|
break;
|
||||||
|
@ -16,6 +16,7 @@ using CppType = Il2CppSystem.Type;
|
|||||||
using BF = System.Reflection.BindingFlags;
|
using BF = System.Reflection.BindingFlags;
|
||||||
using UnityExplorer.Core.Config;
|
using UnityExplorer.Core.Config;
|
||||||
using UnhollowerBaseLib.Attributes;
|
using UnhollowerBaseLib.Attributes;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace UnityExplorer
|
namespace UnityExplorer
|
||||||
{
|
{
|
||||||
@ -25,10 +26,15 @@ namespace UnityExplorer
|
|||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
|
float start = Time.realtimeSinceStartup;
|
||||||
TryLoadGameModules();
|
TryLoadGameModules();
|
||||||
|
ExplorerCore.Log($"Loaded Unhollowed modules in {Time.realtimeSinceStartup - start} seconds");
|
||||||
|
|
||||||
|
start = Time.realtimeSinceStartup;
|
||||||
BuildDeobfuscationCache();
|
BuildDeobfuscationCache();
|
||||||
OnTypeLoaded += TryCacheDeobfuscatedType;
|
OnTypeLoaded += TryCacheDeobfuscatedType;
|
||||||
|
ExplorerCore.Log($"Setup IL2CPP reflection in {Time.realtimeSinceStartup - start} seconds, " +
|
||||||
|
$"deobfuscated types count: {DeobfuscatedTypes.Count}");
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IL2CPP Extern and pointers
|
#region IL2CPP Extern and pointers
|
||||||
@ -67,19 +73,11 @@ namespace UnityExplorer
|
|||||||
|
|
||||||
private static void BuildDeobfuscationCache()
|
private static void BuildDeobfuscationCache()
|
||||||
{
|
{
|
||||||
float start = UnityEngine.Time.realtimeSinceStartup;
|
|
||||||
|
|
||||||
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
|
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
|
||||||
{
|
{
|
||||||
foreach (var type in asm.TryGetTypes())
|
foreach (var type in asm.TryGetTypes())
|
||||||
TryCacheDeobfuscatedType(type);
|
TryCacheDeobfuscatedType(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DeobfuscatedTypes.Count > 0)
|
|
||||||
{
|
|
||||||
ExplorerCore.Log($"Built deobfuscation cache in {UnityEngine.Time.realtimeSinceStartup - start} seconds, " +
|
|
||||||
$"initial count: {DeobfuscatedTypes.Count} ");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void TryCacheDeobfuscatedType(Type type)
|
private static void TryCacheDeobfuscatedType(Type type)
|
||||||
@ -464,7 +462,7 @@ namespace UnityExplorer
|
|||||||
#if ML
|
#if ML
|
||||||
Path.Combine("MelonLoader", "Managed")
|
Path.Combine("MelonLoader", "Managed")
|
||||||
#elif BIE
|
#elif BIE
|
||||||
Path.Combine("BepInEx", "unhollowed")
|
Path.Combine(BepInEx.Paths.BepInExRootPath, "unhollowed")
|
||||||
#else
|
#else
|
||||||
Path.Combine(ExplorerCore.Loader.ExplorerFolder, "Modules")
|
Path.Combine(ExplorerCore.Loader.ExplorerFolder, "Modules")
|
||||||
#endif
|
#endif
|
||||||
|
@ -4,11 +4,11 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using BF = System.Reflection.BindingFlags;
|
|
||||||
using UnityExplorer.Core.Runtime;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityExplorer.Core.Config;
|
using UnityExplorer.Core.Config;
|
||||||
|
using UnityExplorer.Core.Runtime;
|
||||||
|
using BF = System.Reflection.BindingFlags;
|
||||||
|
|
||||||
namespace UnityExplorer
|
namespace UnityExplorer
|
||||||
{
|
{
|
||||||
@ -42,7 +42,7 @@ namespace UnityExplorer
|
|||||||
public static Action<Type> OnTypeLoaded;
|
public static Action<Type> OnTypeLoaded;
|
||||||
|
|
||||||
/// <summary>Key: Type.FullName</summary>
|
/// <summary>Key: Type.FullName</summary>
|
||||||
public static readonly SortedDictionary<string, Type> AllTypes = new SortedDictionary<string, Type>(StringComparer.OrdinalIgnoreCase);
|
protected static readonly SortedDictionary<string, Type> AllTypes = new SortedDictionary<string, Type>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
public static readonly List<string> AllNamespaces = new List<string>();
|
public static readonly List<string> AllNamespaces = new List<string>();
|
||||||
private static readonly HashSet<string> uniqueNamespaces = new HashSet<string>();
|
private static readonly HashSet<string> uniqueNamespaces = new HashSet<string>();
|
||||||
@ -65,10 +65,14 @@ namespace UnityExplorer
|
|||||||
|
|
||||||
private static void SetupTypeCache()
|
private static void SetupTypeCache()
|
||||||
{
|
{
|
||||||
|
float start = Time.realtimeSinceStartup;
|
||||||
|
|
||||||
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
|
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
|
||||||
CacheTypes(asm);
|
CacheTypes(asm);
|
||||||
|
|
||||||
AppDomain.CurrentDomain.AssemblyLoad += AssemblyLoaded;
|
AppDomain.CurrentDomain.AssemblyLoad += AssemblyLoaded;
|
||||||
|
|
||||||
|
ExplorerCore.Log($"Cached AppDomain assemblies in {Time.realtimeSinceStartup - start} seconds");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AssemblyLoaded(object sender, AssemblyLoadEventArgs args)
|
private static void AssemblyLoaded(object sender, AssemblyLoadEventArgs args)
|
||||||
@ -83,6 +87,7 @@ namespace UnityExplorer
|
|||||||
{
|
{
|
||||||
foreach (var type in asm.TryGetTypes())
|
foreach (var type in asm.TryGetTypes())
|
||||||
{
|
{
|
||||||
|
// Cache namespace if there is one
|
||||||
if (!string.IsNullOrEmpty(type.Namespace) && !uniqueNamespaces.Contains(type.Namespace))
|
if (!string.IsNullOrEmpty(type.Namespace) && !uniqueNamespaces.Contains(type.Namespace))
|
||||||
{
|
{
|
||||||
uniqueNamespaces.Add(type.Namespace);
|
uniqueNamespaces.Add(type.Namespace);
|
||||||
@ -96,16 +101,16 @@ namespace UnityExplorer
|
|||||||
AllNamespaces.Insert(i, type.Namespace);
|
AllNamespaces.Insert(i, type.Namespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cache the type. Overwrite type if one exists with the full name
|
||||||
if (AllTypes.ContainsKey(type.FullName))
|
if (AllTypes.ContainsKey(type.FullName))
|
||||||
AllTypes[type.FullName] = type;
|
AllTypes[type.FullName] = type;
|
||||||
else
|
else
|
||||||
{
|
|
||||||
AllTypes.Add(type.FullName, type);
|
AllTypes.Add(type.FullName, type);
|
||||||
//allTypeNames.Add(type.FullName);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Invoke listener
|
||||||
OnTypeLoaded?.Invoke(type);
|
OnTypeLoaded?.Invoke(type);
|
||||||
|
|
||||||
|
// Check type inheritance cache, add this to any lists it should be in
|
||||||
foreach (var key in typeInheritance.Keys)
|
foreach (var key in typeInheritance.Keys)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -150,13 +155,6 @@ namespace UnityExplorer
|
|||||||
internal virtual string Internal_ProcessTypeInString(string theString, Type type)
|
internal virtual string Internal_ProcessTypeInString(string theString, Type type)
|
||||||
=> theString;
|
=> theString;
|
||||||
|
|
||||||
//// Force loading modules
|
|
||||||
//public static bool LoadModule(string moduleName)
|
|
||||||
// => Instance.Internal_LoadModule(moduleName);
|
|
||||||
//
|
|
||||||
//internal virtual bool Internal_LoadModule(string moduleName)
|
|
||||||
// => false;
|
|
||||||
|
|
||||||
// Singleton finder
|
// Singleton finder
|
||||||
|
|
||||||
public static void FindSingleton(string[] possibleNames, Type type, BindingFlags flags, List<object> instances)
|
public static void FindSingleton(string[] possibleNames, Type type, BindingFlags flags, List<object> instances)
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityExplorer.UI.CacheObject.IValues;
|
|
||||||
using System.Reflection;
|
|
||||||
using UnityExplorer.UI;
|
using UnityExplorer.UI;
|
||||||
|
using UnityExplorer.UI.CacheObject.IValues;
|
||||||
#if CPP
|
#if CPP
|
||||||
using UnhollowerRuntimeLib;
|
using UnhollowerRuntimeLib;
|
||||||
using UnhollowerBaseLib;
|
using UnhollowerBaseLib;
|
||||||
|
@ -20,7 +20,7 @@ namespace UnityExplorer
|
|||||||
public static class ExplorerCore
|
public static class ExplorerCore
|
||||||
{
|
{
|
||||||
public const string NAME = "UnityExplorer";
|
public const string NAME = "UnityExplorer";
|
||||||
public const string VERSION = "4.0.8";
|
public const string VERSION = "4.1.6";
|
||||||
public const string AUTHOR = "Sinai";
|
public const string AUTHOR = "Sinai";
|
||||||
public const string GUID = "com.sinai.unityexplorer";
|
public const string GUID = "com.sinai.unityexplorer";
|
||||||
|
|
||||||
|
@ -11,18 +11,17 @@
|
|||||||
|
|
||||||
<!-- MonoMod for MelonLoader 0.3.0 -->
|
<!-- MonoMod for MelonLoader 0.3.0 -->
|
||||||
<ItemGroup Condition="'$(IsMelonLoaderLegacy)'=='true'">
|
<ItemGroup Condition="'$(IsMelonLoaderLegacy)'=='true'">
|
||||||
<InputAssemblies Include="..\lib\HarmonyX\Harmony\bin\Release\net45\Mono.Cecil.dll" />
|
<InputAssemblies Include="packages\Mono.Cecil.0.10.4\lib\net35\Mono.Cecil.dll" />
|
||||||
<InputAssemblies Include="..\lib\HarmonyX\Harmony\bin\Release\net45\Mono.Cecil.Mdb.dll" />
|
<InputAssemblies Include="packages\Mono.Cecil.0.10.4\lib\net35\Mono.Cecil.Mdb.dll" />
|
||||||
<InputAssemblies Include="..\lib\HarmonyX\Harmony\bin\Release\net45\Mono.Cecil.Pdb.dll" />
|
<InputAssemblies Include="packages\Mono.Cecil.0.10.4\lib\net35\Mono.Cecil.Pdb.dll" />
|
||||||
<InputAssemblies Include="..\lib\HarmonyX\Harmony\bin\Release\net45\Mono.Cecil.Rocks.dll" />
|
<InputAssemblies Include="packages\Mono.Cecil.0.10.4\lib\net35\Mono.Cecil.Rocks.dll" />
|
||||||
<InputAssemblies Include="..\lib\HarmonyX\Harmony\bin\Release\net45\MonoMod.RuntimeDetour.dll" />
|
<InputAssemblies Include="packages\MonoMod.RuntimeDetour.20.1.1.4\lib\net35\MonoMod.RuntimeDetour.dll" />
|
||||||
<InputAssemblies Include="..\lib\HarmonyX\Harmony\bin\Release\net45\MonoMod.Utils.dll" />
|
<InputAssemblies Include="packages\MonoMod.Utils.20.1.1.4\lib\net35\MonoMod.Utils.dll" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Required references for ILRepack -->
|
<!-- Required references for ILRepack -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ReferenceFolders Include="..\lib\" />
|
<ReferenceFolders Include="packages\HarmonyX.2.4.2\lib\net35\" />
|
||||||
<ReferenceFolders Include="..\lib\HarmonyX\Harmony\bin\Release\net35\" />
|
|
||||||
<ReferenceFolders Include="..\lib\BepInEx.6.IL2CPP\" />
|
<ReferenceFolders Include="..\lib\BepInEx.6.IL2CPP\" />
|
||||||
<ReferenceFolders Include="..\lib\BepInEx.6.Mono\" />
|
<ReferenceFolders Include="..\lib\BepInEx.6.Mono\" />
|
||||||
<ReferenceFolders Include="..\lib\BepInEx.5\" />
|
<ReferenceFolders Include="..\lib\BepInEx.5\" />
|
||||||
@ -36,7 +35,8 @@
|
|||||||
LibraryPath="@(ReferenceFolders)"
|
LibraryPath="@(ReferenceFolders)"
|
||||||
InputAssemblies="@(InputAssemblies)"
|
InputAssemblies="@(InputAssemblies)"
|
||||||
TargetKind="Dll"
|
TargetKind="Dll"
|
||||||
OutputFile="$(OutputPath)$(AssemblyName).dll" />
|
OutputFile="$(OutputPath)$(AssemblyName).dll"
|
||||||
|
/>
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
@ -21,11 +21,7 @@ namespace UnityExplorer.Loader.BIE
|
|||||||
|
|
||||||
public override void RegisterConfigElement<T>(ConfigElement<T> config)
|
public override void RegisterConfigElement<T>(ConfigElement<T> config)
|
||||||
{
|
{
|
||||||
object[] tags = null;
|
var entry = Config.Bind(CTG_NAME, config.Name, config.Value, config.Description);
|
||||||
if (config.IsInternal)
|
|
||||||
tags = new[] { "Advanced" };
|
|
||||||
|
|
||||||
var entry = Config.Bind(CTG_NAME, config.Name, config.Value, new ConfigDescription(config.Description, null, tags));
|
|
||||||
|
|
||||||
entry.SettingChanged += (object o, EventArgs e) =>
|
entry.SettingChanged += (object o, EventArgs e) =>
|
||||||
{
|
{
|
||||||
|
@ -7,12 +7,12 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityExplorer.Core.Config;
|
|
||||||
using UnityExplorer.Loader.BIE;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityExplorer.Core;
|
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
|
using UnityExplorer.Core;
|
||||||
|
using UnityExplorer.Core.Config;
|
||||||
using UnityExplorer.Core.Input;
|
using UnityExplorer.Core.Input;
|
||||||
|
using UnityExplorer.Loader.BIE;
|
||||||
#if CPP
|
#if CPP
|
||||||
using BepInEx.IL2CPP;
|
using BepInEx.IL2CPP;
|
||||||
using UnhollowerRuntimeLib;
|
using UnhollowerRuntimeLib;
|
||||||
@ -46,7 +46,6 @@ namespace UnityExplorer
|
|||||||
private static readonly Harmony s_harmony = new Harmony(ExplorerCore.GUID);
|
private static readonly Harmony s_harmony = new Harmony(ExplorerCore.GUID);
|
||||||
|
|
||||||
public string ExplorerFolder => Path.Combine(Paths.PluginPath, ExplorerCore.NAME);
|
public string ExplorerFolder => Path.Combine(Paths.PluginPath, ExplorerCore.NAME);
|
||||||
public string ConfigFolder => Path.Combine(Paths.ConfigPath, ExplorerCore.NAME);
|
|
||||||
|
|
||||||
public Action<object> OnLogMessage => LogSource.LogMessage;
|
public Action<object> OnLogMessage => LogSource.LogMessage;
|
||||||
public Action<object> OnLogWarning => LogSource.LogWarning;
|
public Action<object> OnLogWarning => LogSource.LogWarning;
|
||||||
|
@ -10,7 +10,6 @@ namespace UnityExplorer
|
|||||||
{
|
{
|
||||||
string ExplorerFolder { get; }
|
string ExplorerFolder { get; }
|
||||||
|
|
||||||
string ConfigFolder { get; }
|
|
||||||
ConfigHandler ConfigHandler { get; }
|
ConfigHandler ConfigHandler { get; }
|
||||||
|
|
||||||
Action<object> OnLogMessage { get; }
|
Action<object> OnLogMessage { get; }
|
||||||
|
@ -27,7 +27,6 @@ namespace UnityExplorer
|
|||||||
public static ExplorerMelonMod Instance;
|
public static ExplorerMelonMod Instance;
|
||||||
|
|
||||||
public string ExplorerFolder => Path.Combine("Mods", ExplorerCore.NAME);
|
public string ExplorerFolder => Path.Combine("Mods", ExplorerCore.NAME);
|
||||||
public string ConfigFolder => ExplorerFolder;
|
|
||||||
|
|
||||||
public ConfigHandler ConfigHandler => _configHandler;
|
public ConfigHandler ConfigHandler => _configHandler;
|
||||||
public MelonLoaderConfigHandler _configHandler;
|
public MelonLoaderConfigHandler _configHandler;
|
||||||
|
@ -76,8 +76,6 @@ namespace UnityExplorer
|
|||||||
}
|
}
|
||||||
private static string s_explorerFolder;
|
private static string s_explorerFolder;
|
||||||
|
|
||||||
public string ConfigFolder => ExplorerFolder;
|
|
||||||
|
|
||||||
Action<object> IExplorerLoader.OnLogMessage => (object log) => { OnLog?.Invoke(log?.ToString() ?? "", LogType.Log); };
|
Action<object> IExplorerLoader.OnLogMessage => (object log) => { OnLog?.Invoke(log?.ToString() ?? "", LogType.Log); };
|
||||||
Action<object> IExplorerLoader.OnLogWarning => (object log) => { OnLog?.Invoke(log?.ToString() ?? "", LogType.Warning); };
|
Action<object> IExplorerLoader.OnLogWarning => (object log) => { OnLog?.Invoke(log?.ToString() ?? "", LogType.Warning); };
|
||||||
Action<object> IExplorerLoader.OnLogError => (object log) => { OnLog?.Invoke(log?.ToString() ?? "", LogType.Error); };
|
Action<object> IExplorerLoader.OnLogError => (object log) => { OnLog?.Invoke(log?.ToString() ?? "", LogType.Error); };
|
||||||
|
@ -13,11 +13,11 @@ namespace UnityExplorer.Loader.STANDALONE
|
|||||||
public class StandaloneConfigHandler : ConfigHandler
|
public class StandaloneConfigHandler : ConfigHandler
|
||||||
{
|
{
|
||||||
internal static IniDataParser _parser;
|
internal static IniDataParser _parser;
|
||||||
internal static string INI_PATH;
|
internal static string CONFIG_PATH;
|
||||||
|
|
||||||
public override void Init()
|
public override void Init()
|
||||||
{
|
{
|
||||||
INI_PATH = Path.Combine(ExplorerCore.Loader.ConfigFolder, "config.ini");
|
CONFIG_PATH = Path.Combine(ExplorerCore.Loader.ExplorerFolder, "config.ini");
|
||||||
_parser = new IniDataParser();
|
_parser = new IniDataParser();
|
||||||
_parser.Configuration.CommentString = "#";
|
_parser.Configuration.CommentString = "#";
|
||||||
}
|
}
|
||||||
@ -49,10 +49,10 @@ namespace UnityExplorer.Loader.STANDALONE
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!File.Exists(INI_PATH))
|
if (!File.Exists(CONFIG_PATH))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
string ini = File.ReadAllText(INI_PATH);
|
string ini = File.ReadAllText(CONFIG_PATH);
|
||||||
|
|
||||||
var data = _parser.Parse(ini);
|
var data = _parser.Parse(ini);
|
||||||
|
|
||||||
@ -97,10 +97,10 @@ namespace UnityExplorer.Loader.STANDALONE
|
|||||||
foreach (var entry in ConfigManager.ConfigElements)
|
foreach (var entry in ConfigManager.ConfigElements)
|
||||||
sec.AddKey(entry.Key, entry.Value.BoxedValue.ToString());
|
sec.AddKey(entry.Key, entry.Value.BoxedValue.ToString());
|
||||||
|
|
||||||
if (!Directory.Exists(ExplorerCore.Loader.ConfigFolder))
|
if (!Directory.Exists(ExplorerCore.Loader.ExplorerFolder))
|
||||||
Directory.CreateDirectory(ExplorerCore.Loader.ConfigFolder);
|
Directory.CreateDirectory(ExplorerCore.Loader.ExplorerFolder);
|
||||||
|
|
||||||
File.WriteAllText(INI_PATH, data.ToString());
|
File.WriteAllText(CONFIG_PATH, data.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ namespace UnityExplorer.UI.CSConsole
|
|||||||
AutoCompleteModal.Instance.ReleaseOwnership(this);
|
AutoCompleteModal.Instance.ReleaseOwnership(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delimiters for completions, notably does not include '.'
|
|
||||||
private readonly HashSet<char> delimiters = new HashSet<char>
|
private readonly HashSet<char> delimiters = new HashSet<char>
|
||||||
{
|
{
|
||||||
'{', '}', ',', ';', '<', '>', '(', ')', '[', ']', '=', '|', '&', '?'
|
'{', '}', ',', ';', '<', '>', '(', ')', '[', ']', '=', '|', '&', '?'
|
||||||
@ -41,7 +40,7 @@ namespace UnityExplorer.UI.CSConsole
|
|||||||
suggestions.Clear();
|
suggestions.Clear();
|
||||||
|
|
||||||
int caret = Math.Max(0, Math.Min(InputField.Text.Length - 1, InputField.Component.caretPosition - 1));
|
int caret = Math.Max(0, Math.Min(InputField.Text.Length - 1, InputField.Component.caretPosition - 1));
|
||||||
int start = caret;
|
int startIdx = caret;
|
||||||
|
|
||||||
// If the character at the caret index is whitespace or delimiter,
|
// If the character at the caret index is whitespace or delimiter,
|
||||||
// or if the next character (if it exists) is not whitespace,
|
// or if the next character (if it exists) is not whitespace,
|
||||||
@ -55,17 +54,17 @@ namespace UnityExplorer.UI.CSConsole
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get the current composition string (from caret back to last delimiter)
|
// get the current composition string (from caret back to last delimiter)
|
||||||
while (start > 0)
|
while (startIdx > 0)
|
||||||
{
|
{
|
||||||
start--;
|
startIdx--;
|
||||||
char c = InputField.Text[start];
|
char c = InputField.Text[startIdx];
|
||||||
if (delimiters.Contains(c))
|
if (delimiters.Contains(c) || char.IsWhiteSpace(c))
|
||||||
{
|
{
|
||||||
start++;
|
startIdx++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string input = InputField.Text.Substring(start, caret - start + 1);
|
string input = InputField.Text.Substring(startIdx, caret - startIdx + 1);
|
||||||
|
|
||||||
// Get MCS completions
|
// Get MCS completions
|
||||||
|
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
using System;
|
using Mono.CSharp;
|
||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.UI.CSConsole;
|
|
||||||
using UnityExplorer.Core.Input;
|
using UnityExplorer.Core.Input;
|
||||||
|
using UnityExplorer.UI.CSConsole;
|
||||||
using UnityExplorer.UI.Panels;
|
using UnityExplorer.UI.Panels;
|
||||||
using UnityExplorer.UI.Widgets.AutoComplete;
|
using UnityExplorer.UI.Widgets.AutoComplete;
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CSConsole
|
namespace UnityExplorer.UI.CSConsole
|
||||||
{
|
{
|
||||||
@ -35,6 +36,8 @@ namespace UnityExplorer.UI.CSConsole
|
|||||||
public static bool EnableAutoIndent { get; private set; } = true;
|
public static bool EnableAutoIndent { get; private set; } = true;
|
||||||
public static bool EnableSuggestions { get; private set; } = true;
|
public static bool EnableSuggestions { get; private set; } = true;
|
||||||
|
|
||||||
|
internal static string ScriptsFolder => Path.Combine(ExplorerCore.Loader.ExplorerFolder, "Scripts");
|
||||||
|
|
||||||
internal static readonly string[] DefaultUsing = new string[]
|
internal static readonly string[] DefaultUsing = new string[]
|
||||||
{
|
{
|
||||||
"System",
|
"System",
|
||||||
@ -55,6 +58,18 @@ namespace UnityExplorer.UI.CSConsole
|
|||||||
ResetConsole(false);
|
ResetConsole(false);
|
||||||
// ensure the compiler is supported (if this fails then SRE is probably stubbed)
|
// ensure the compiler is supported (if this fails then SRE is probably stubbed)
|
||||||
Evaluator.Compile("0 == 0");
|
Evaluator.Compile("0 == 0");
|
||||||
|
|
||||||
|
if (!Directory.Exists(ScriptsFolder))
|
||||||
|
Directory.CreateDirectory(ScriptsFolder);
|
||||||
|
|
||||||
|
var startupPath = Path.Combine(ScriptsFolder, "startup.cs");
|
||||||
|
if (File.Exists(startupPath))
|
||||||
|
{
|
||||||
|
ExplorerCore.Log($"Executing startup script from '{startupPath}'...");
|
||||||
|
var text = File.ReadAllText(startupPath);
|
||||||
|
Input.Text = text;
|
||||||
|
Evaluate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -68,7 +83,7 @@ namespace UnityExplorer.UI.CSConsole
|
|||||||
SetupHelpInteraction();
|
SetupHelpInteraction();
|
||||||
|
|
||||||
Panel.OnInputChanged += OnInputChanged;
|
Panel.OnInputChanged += OnInputChanged;
|
||||||
Panel.InputScroll.OnScroll += OnInputScrolled;
|
Panel.InputScroller.OnScroll += OnInputScrolled;
|
||||||
Panel.OnCompileClicked += Evaluate;
|
Panel.OnCompileClicked += Evaluate;
|
||||||
Panel.OnResetClicked += ResetConsole;
|
Panel.OnResetClicked += ResetConsole;
|
||||||
Panel.OnHelpDropdownChanged += HelpSelected;
|
Panel.OnHelpDropdownChanged += HelpSelected;
|
||||||
@ -150,15 +165,16 @@ namespace UnityExplorer.UI.CSConsole
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Try to "Compile" the code (tries to interpret it as REPL)
|
// Compile the code. If it returned a CompiledMethod, it is REPL.
|
||||||
var evaluation = Evaluator.Compile(input);
|
CompiledMethod repl = Evaluator.Compile(input);
|
||||||
if (evaluation != null)
|
|
||||||
|
if (repl != null)
|
||||||
{
|
{
|
||||||
// Valid REPL, we have a delegate to the evaluation.
|
// Valid REPL, we have a delegate to the evaluation.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
object ret = null;
|
object ret = null;
|
||||||
evaluation.Invoke(ref ret);
|
repl.Invoke(ref ret);
|
||||||
var result = ret?.ToString();
|
var result = ret?.ToString();
|
||||||
if (!string.IsNullOrEmpty(result))
|
if (!string.IsNullOrEmpty(result))
|
||||||
ExplorerCore.Log($"Invoked REPL, result: {ret}");
|
ExplorerCore.Log($"Invoked REPL, result: {ret}");
|
||||||
@ -172,9 +188,7 @@ namespace UnityExplorer.UI.CSConsole
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// The input was not recognized as an evaluation. Compile the code.
|
// The compiled code was not REPL, so it was a using directive or it defined classes.
|
||||||
|
|
||||||
Evaluator.Run(input);
|
|
||||||
|
|
||||||
string output = ScriptEvaluator._textWriter.ToString();
|
string output = ScriptEvaluator._textWriter.ToString();
|
||||||
var outputSplit = output.Split('\n');
|
var outputSplit = output.Split('\n');
|
||||||
@ -231,19 +245,26 @@ namespace UnityExplorer.UI.CSConsole
|
|||||||
previousInput = value;
|
previousInput = value;
|
||||||
|
|
||||||
if (EnableSuggestions && AutoCompleteModal.CheckEnter(Completer))
|
if (EnableSuggestions && AutoCompleteModal.CheckEnter(Completer))
|
||||||
{
|
|
||||||
OnAutocompleteEnter();
|
OnAutocompleteEnter();
|
||||||
}
|
|
||||||
else if (!settingCaretCoroutine)
|
|
||||||
{
|
|
||||||
if (EnableSuggestions)
|
|
||||||
Completer.CheckAutocompletes();
|
|
||||||
|
|
||||||
|
if (!settingCaretCoroutine)
|
||||||
|
{
|
||||||
if (EnableAutoIndent)
|
if (EnableAutoIndent)
|
||||||
DoAutoIndent();
|
DoAutoIndent();
|
||||||
}
|
}
|
||||||
|
|
||||||
HighlightVisibleInput();
|
var inStringOrComment = HighlightVisibleInput();
|
||||||
|
|
||||||
|
if (!settingCaretCoroutine)
|
||||||
|
{
|
||||||
|
if (EnableSuggestions)
|
||||||
|
{
|
||||||
|
if (inStringOrComment)
|
||||||
|
AutoCompleteModal.Instance.ReleaseOwnership(Completer);
|
||||||
|
else
|
||||||
|
Completer.CheckAutocompletes();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UpdateCaret(out _);
|
UpdateCaret(out _);
|
||||||
}
|
}
|
||||||
@ -257,16 +278,16 @@ namespace UnityExplorer.UI.CSConsole
|
|||||||
|
|
||||||
UpdateCaret(out bool caretMoved);
|
UpdateCaret(out bool caretMoved);
|
||||||
|
|
||||||
if (!settingCaretCoroutine && EnableSuggestions && AutoCompleteModal.CheckEscape(Completer))
|
if (!settingCaretCoroutine && EnableSuggestions)
|
||||||
|
{
|
||||||
|
if (AutoCompleteModal.CheckEscape(Completer))
|
||||||
{
|
{
|
||||||
OnAutocompleteEscaped();
|
OnAutocompleteEscaped();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!settingCaretCoroutine && EnableSuggestions && caretMoved)
|
if (caretMoved)
|
||||||
{
|
|
||||||
AutoCompleteModal.Instance.ReleaseOwnership(Completer);
|
AutoCompleteModal.Instance.ReleaseOwnership(Completer);
|
||||||
//Completer.CheckAutocompletes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EnableCtrlRShortcut
|
if (EnableCtrlRShortcut
|
||||||
@ -310,7 +331,7 @@ namespace UnityExplorer.UI.CSConsole
|
|||||||
var charBot = charTop - CSCONSOLE_LINEHEIGHT;
|
var charBot = charTop - CSCONSOLE_LINEHEIGHT;
|
||||||
|
|
||||||
var viewportMin = Input.Rect.rect.height - Input.Rect.anchoredPosition.y - (Input.Rect.rect.height * 0.5f);
|
var viewportMin = Input.Rect.rect.height - Input.Rect.anchoredPosition.y - (Input.Rect.rect.height * 0.5f);
|
||||||
var viewportMax = viewportMin - Panel.InputScroll.ViewportRect.rect.height;
|
var viewportMax = viewportMin - Panel.InputScroller.ViewportRect.rect.height;
|
||||||
|
|
||||||
float diff = 0f;
|
float diff = 0f;
|
||||||
if (charTop > viewportMin)
|
if (charTop > viewportMin)
|
||||||
@ -330,7 +351,7 @@ namespace UnityExplorer.UI.CSConsole
|
|||||||
{
|
{
|
||||||
settingCaretCoroutine = true;
|
settingCaretCoroutine = true;
|
||||||
Input.Component.readOnly = true;
|
Input.Component.readOnly = true;
|
||||||
RuntimeProvider.Instance.StartCoroutine(SetAutocompleteCaretCoro(caretPosition));
|
RuntimeProvider.Instance.StartCoroutine(SetCaretCoroutine(caretPosition));
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static PropertyInfo SelectionGuardProperty => selectionGuardPropInfo ?? GetSelectionGuardPropInfo();
|
internal static PropertyInfo SelectionGuardProperty => selectionGuardPropInfo ?? GetSelectionGuardPropInfo();
|
||||||
@ -345,7 +366,7 @@ namespace UnityExplorer.UI.CSConsole
|
|||||||
|
|
||||||
private static PropertyInfo selectionGuardPropInfo;
|
private static PropertyInfo selectionGuardPropInfo;
|
||||||
|
|
||||||
private static IEnumerator SetAutocompleteCaretCoro(int caretPosition)
|
private static IEnumerator SetCaretCoroutine(int caretPosition)
|
||||||
{
|
{
|
||||||
var color = Input.Component.selectionColor;
|
var color = Input.Component.selectionColor;
|
||||||
color.a = 0f;
|
color.a = 0f;
|
||||||
@ -369,25 +390,29 @@ namespace UnityExplorer.UI.CSConsole
|
|||||||
settingCaretCoroutine = false;
|
settingCaretCoroutine = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#region Lexer Highlighting
|
#region Lexer Highlighting
|
||||||
|
|
||||||
private static void HighlightVisibleInput()
|
/// <summary>
|
||||||
|
/// Returns true if caret is inside string or comment, false otherwise
|
||||||
|
/// </summary>
|
||||||
|
private static bool HighlightVisibleInput()
|
||||||
{
|
{
|
||||||
int startIdx = 0;
|
if (string.IsNullOrEmpty(Input.Text))
|
||||||
int endIdx = Input.Text.Length - 1;
|
{
|
||||||
int topLine = 0;
|
Panel.HighlightText.text = "";
|
||||||
|
Panel.LineNumberText.text = "1";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Calculate visible text if necessary
|
// Calculate the visible lines
|
||||||
if (Input.Rect.rect.height > Panel.InputScroll.ViewportRect.rect.height)
|
|
||||||
{
|
int topLine = -1;
|
||||||
topLine = -1;
|
|
||||||
int bottomLine = -1;
|
int bottomLine = -1;
|
||||||
|
|
||||||
// the top and bottom position of the viewport in relation to the text height
|
// the top and bottom position of the viewport in relation to the text height
|
||||||
// they need the half-height adjustment to normalize against the 'line.topY' value.
|
// they need the half-height adjustment to normalize against the 'line.topY' value.
|
||||||
var viewportMin = Input.Rect.rect.height - Input.Rect.anchoredPosition.y - (Input.Rect.rect.height * 0.5f);
|
var viewportMin = Input.Rect.rect.height - Input.Rect.anchoredPosition.y - (Input.Rect.rect.height * 0.5f);
|
||||||
var viewportMax = viewportMin - Panel.InputScroll.ViewportRect.rect.height;
|
var viewportMax = viewportMin - Panel.InputScroller.ViewportRect.rect.height;
|
||||||
|
|
||||||
for (int i = 0; i < Input.TextGenerator.lineCount; i++)
|
for (int i = 0; i < Input.TextGenerator.lineCount; i++)
|
||||||
{
|
{
|
||||||
@ -403,14 +428,53 @@ namespace UnityExplorer.UI.CSConsole
|
|||||||
topLine = Math.Max(0, topLine - 1);
|
topLine = Math.Max(0, topLine - 1);
|
||||||
bottomLine = Math.Min(Input.TextGenerator.lineCount - 1, bottomLine + 1);
|
bottomLine = Math.Min(Input.TextGenerator.lineCount - 1, bottomLine + 1);
|
||||||
|
|
||||||
startIdx = Input.TextGenerator.lines[topLine].startCharIdx;
|
int startIdx = Input.TextGenerator.lines[topLine].startCharIdx;
|
||||||
endIdx = (bottomLine >= Input.TextGenerator.lineCount - 1)
|
int endIdx = (bottomLine >= Input.TextGenerator.lineCount - 1)
|
||||||
? Input.Text.Length - 1
|
? Input.Text.Length - 1
|
||||||
: (Input.TextGenerator.lines[bottomLine + 1].startCharIdx - 1);
|
: (Input.TextGenerator.lines[bottomLine + 1].startCharIdx - 1);
|
||||||
}
|
|
||||||
|
|
||||||
// Highlight the visible text with the LexerBuilder
|
// Highlight the visible text with the LexerBuilder
|
||||||
Panel.HighlightText.text = Lexer.BuildHighlightedString(Input.Text, startIdx, endIdx, topLine);
|
|
||||||
|
Panel.HighlightText.text = Lexer.BuildHighlightedString(Input.Text, startIdx, endIdx, topLine, LastCaretPosition, out bool ret);
|
||||||
|
|
||||||
|
// Set the line numbers
|
||||||
|
|
||||||
|
// determine true starting line number (not the same as the cached TextGenerator line numbers)
|
||||||
|
int realStartLine = 0;
|
||||||
|
for (int i = 0; i < startIdx; i++)
|
||||||
|
{
|
||||||
|
if (LexerBuilder.IsNewLine(Input.Text[i]))
|
||||||
|
realStartLine++;
|
||||||
|
}
|
||||||
|
realStartLine++;
|
||||||
|
char lastPrev = '\n';
|
||||||
|
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
|
||||||
|
// append leading new lines for spacing (no point rendering line numbers we cant see)
|
||||||
|
for (int i = 0; i < topLine; i++)
|
||||||
|
sb.Append('\n');
|
||||||
|
|
||||||
|
// append the displayed line numbers
|
||||||
|
for (int i = topLine; i <= bottomLine; i++)
|
||||||
|
{
|
||||||
|
if (i > 0)
|
||||||
|
lastPrev = Input.Text[Input.TextGenerator.lines[i].startCharIdx - 1];
|
||||||
|
|
||||||
|
// previous line ended with a newline character, this is an actual new line.
|
||||||
|
if (LexerBuilder.IsNewLine(lastPrev))
|
||||||
|
{
|
||||||
|
sb.Append(realStartLine.ToString());
|
||||||
|
realStartLine++;
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.Append('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
Panel.LineNumberText.text = sb.ToString();
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -544,7 +608,9 @@ If the game was built with Unity's stubbed netstandard 2.0 runtime, you can fix
|
|||||||
internal const string STARTUP_TEXT = @"<color=#5d8556>// Welcome to the UnityExplorer C# Console!
|
internal const string STARTUP_TEXT = @"<color=#5d8556>// Welcome to the UnityExplorer C# Console!
|
||||||
|
|
||||||
// It is recommended to use the Log panel (or a console log window) while using this tool.
|
// It is recommended to use the Log panel (or a console log window) while using this tool.
|
||||||
// Use the Help dropdown to see detailed examples of how to use the console.</color>";
|
// Use the Help dropdown to see detailed examples of how to use the console.
|
||||||
|
|
||||||
|
// To execute a script automatically on startup, put the script at 'UnityExplorer\Scripts\startup.cs'</color>";
|
||||||
|
|
||||||
internal const string HELP_USINGS = @"// You can add a using directive to any namespace, but you must compile for it to take effect.
|
internal const string HELP_USINGS = @"// You can add a using directive to any namespace, but you must compile for it to take effect.
|
||||||
// It will remain in effect until you Reset the console.
|
// It will remain in effect until you Reset the console.
|
||||||
|
@ -13,6 +13,8 @@ namespace UnityExplorer.UI.CSConsole
|
|||||||
{
|
{
|
||||||
public int startIndex;
|
public int startIndex;
|
||||||
public int endIndex;
|
public int endIndex;
|
||||||
|
public bool isStringOrComment;
|
||||||
|
public bool matchToEndOfLine;
|
||||||
public string htmlColorTag;
|
public string htmlColorTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,8 +84,10 @@ namespace UnityExplorer.UI.CSConsole
|
|||||||
/// <param name="endIdx">The last character you want to highlight</param>
|
/// <param name="endIdx">The last character you want to highlight</param>
|
||||||
/// <param name="leadingLines">The amount of leading empty lines you want before the first character in the return string.</param>
|
/// <param name="leadingLines">The amount of leading empty lines you want before the first character in the return string.</param>
|
||||||
/// <returns>A string which contains the amount of leading lines specified, as well as the rich-text highlighted section.</returns>
|
/// <returns>A string which contains the amount of leading lines specified, as well as the rich-text highlighted section.</returns>
|
||||||
public string BuildHighlightedString(string input, int startIdx, int endIdx, int leadingLines)
|
public string BuildHighlightedString(string input, int startIdx, int endIdx, int leadingLines, int caretIdx, out bool caretInStringOrComment)
|
||||||
{
|
{
|
||||||
|
caretInStringOrComment = false;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(input) || endIdx <= startIdx)
|
if (string.IsNullOrEmpty(input) || endIdx <= startIdx)
|
||||||
return input;
|
return input;
|
||||||
|
|
||||||
@ -105,14 +109,28 @@ namespace UnityExplorer.UI.CSConsole
|
|||||||
|
|
||||||
// append the highlighted match
|
// append the highlighted match
|
||||||
sb.Append(match.htmlColorTag);
|
sb.Append(match.htmlColorTag);
|
||||||
|
|
||||||
for (int i = match.startIndex; i <= match.endIndex && i <= currentEndIdx; i++)
|
for (int i = match.startIndex; i <= match.endIndex && i <= currentEndIdx; i++)
|
||||||
sb.Append(input[i]);
|
sb.Append(input[i]);
|
||||||
|
|
||||||
sb.Append(SignatureHighlighter.CLOSE_COLOR);
|
sb.Append(SignatureHighlighter.CLOSE_COLOR);
|
||||||
|
|
||||||
// update the last unhighlighted start index
|
// update the last unhighlighted start index
|
||||||
lastUnhighlighted = match.endIndex + 1;
|
lastUnhighlighted = match.endIndex + 1;
|
||||||
|
|
||||||
|
int matchEndIdx = match.endIndex;
|
||||||
|
if (match.matchToEndOfLine)
|
||||||
|
{
|
||||||
|
while (input.Length - 1 >= matchEndIdx)
|
||||||
|
{
|
||||||
|
if (IsNewLine(input[matchEndIdx]))
|
||||||
|
break;
|
||||||
|
matchEndIdx++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check caretIdx to determine inStringOrComment state
|
||||||
|
if (caretIdx >= match.startIndex && (caretIdx <= matchEndIdx || (caretIdx >= input.Length && matchEndIdx >= input.Length - 1)))
|
||||||
|
caretInStringOrComment = match.isStringOrComment;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append trailing unhighlighted input
|
// Append trailing unhighlighted input
|
||||||
@ -150,6 +168,7 @@ namespace UnityExplorer.UI.CSConsole
|
|||||||
startIndex = startIndex,
|
startIndex = startIndex,
|
||||||
endIndex = CommittedIndex,
|
endIndex = CommittedIndex,
|
||||||
htmlColorTag = lexer.ColorTag,
|
htmlColorTag = lexer.ColorTag,
|
||||||
|
isStringOrComment = lexer is StringLexer || lexer is CommentLexer,
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,10 @@ namespace UnityExplorer.UI.CSConsole.Lexers
|
|||||||
while (!lexer.EndOfInput && char.IsLetter(lexer.PeekNext()))
|
while (!lexer.EndOfInput && char.IsLetter(lexer.PeekNext()))
|
||||||
sb.Append(lexer.Current);
|
sb.Append(lexer.Current);
|
||||||
|
|
||||||
|
// next must be whitespace or delimiter
|
||||||
|
if (!lexer.EndOfInput && !(char.IsWhiteSpace(lexer.Current) || lexer.IsDelimiter(lexer.Current)))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (keywords.Contains(sb.ToString()))
|
if (keywords.Contains(sb.ToString()))
|
||||||
{
|
{
|
||||||
if (!lexer.EndOfInput)
|
if (!lexer.EndOfInput)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CSConsole.Lexers
|
namespace UnityExplorer.UI.CSConsole.Lexers
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@ namespace UnityExplorer.UI.CSConsole.Lexers
|
|||||||
protected override Color HighlightColor => new Color(0.6f, 0.6f, 0.6f);
|
protected override Color HighlightColor => new Color(0.6f, 0.6f, 0.6f);
|
||||||
|
|
||||||
// all symbols are delimiters
|
// all symbols are delimiters
|
||||||
public override IEnumerable<char> Delimiters => symbols;
|
public override IEnumerable<char> Delimiters => symbols.Where(it => it != '.'); // '.' is not a delimiter, only a separator.
|
||||||
|
|
||||||
public static bool IsSymbol(char c) => symbols.Contains(c);
|
public static bool IsSymbol(char c) => symbols.Contains(c);
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
using System;
|
using Mono.CSharp;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Mono.CSharp;
|
|
||||||
|
|
||||||
// Thanks to ManlyMarco for this
|
// Thanks to ManlyMarco for this
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
using System;
|
using Mono.CSharp;
|
||||||
using Mono.CSharp;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using UnityEngine;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityExplorer.Core.Runtime;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityExplorer.Core.Runtime;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Welcome to the UnityExplorer C# Console!
|
Welcome to the UnityExplorer C# Console!
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityExplorer.UI.CacheObject.Views;
|
|
||||||
using UnityExplorer.UI.CacheObject.IValues;
|
using UnityExplorer.UI.CacheObject.IValues;
|
||||||
|
using UnityExplorer.UI.CacheObject.Views;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CacheObject
|
namespace UnityExplorer.UI.CacheObject
|
||||||
{
|
{
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityExplorer.UI.CacheObject.Views;
|
|
||||||
using UnityExplorer.UI.CacheObject.IValues;
|
using UnityExplorer.UI.CacheObject.IValues;
|
||||||
|
using UnityExplorer.UI.CacheObject.Views;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CacheObject
|
namespace UnityExplorer.UI.CacheObject
|
||||||
{
|
{
|
||||||
|
@ -7,8 +7,8 @@ using System.Text;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.Core.Runtime;
|
using UnityExplorer.Core.Runtime;
|
||||||
using UnityExplorer.UI.CacheObject.Views;
|
|
||||||
using UnityExplorer.UI.CacheObject.IValues;
|
using UnityExplorer.UI.CacheObject.IValues;
|
||||||
|
using UnityExplorer.UI.CacheObject.Views;
|
||||||
using UnityExplorer.UI.Models;
|
using UnityExplorer.UI.Models;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CacheObject
|
namespace UnityExplorer.UI.CacheObject
|
||||||
|
@ -28,10 +28,11 @@ namespace UnityExplorer.UI.CacheObject
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
object ret;
|
||||||
if (HasArguments)
|
if (HasArguments)
|
||||||
return PropertyInfo.GetValue(DeclaringInstance, this.Evaluator.TryParseArguments());
|
ret = PropertyInfo.GetValue(DeclaringInstance, this.Evaluator.TryParseArguments());
|
||||||
|
else
|
||||||
var ret = PropertyInfo.GetValue(DeclaringInstance, null);
|
ret = PropertyInfo.GetValue(DeclaringInstance, null);
|
||||||
HadException = false;
|
HadException = false;
|
||||||
LastException = null;
|
LastException = null;
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -4,8 +4,8 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.UI.Inspectors;
|
|
||||||
using UnityExplorer.UI.CacheObject.IValues;
|
using UnityExplorer.UI.CacheObject.IValues;
|
||||||
|
using UnityExplorer.UI.Inspectors;
|
||||||
using UnityExplorer.UI.Widgets;
|
using UnityExplorer.UI.Widgets;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CacheObject.Views
|
namespace UnityExplorer.UI.CacheObject.Views
|
||||||
|
@ -4,8 +4,8 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.UI.Inspectors;
|
|
||||||
using UnityExplorer.UI.CacheObject.IValues;
|
using UnityExplorer.UI.CacheObject.IValues;
|
||||||
|
using UnityExplorer.UI.Inspectors;
|
||||||
using UnityExplorer.UI.Widgets;
|
using UnityExplorer.UI.Widgets;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CacheObject.Views
|
namespace UnityExplorer.UI.CacheObject.Views
|
||||||
|
@ -147,32 +147,39 @@ namespace UnityExplorer.UI.Inspectors
|
|||||||
var behaviours = GOTarget.GetComponents<Behaviour>();
|
var behaviours = GOTarget.GetComponents<Behaviour>();
|
||||||
|
|
||||||
bool needRefresh = false;
|
bool needRefresh = false;
|
||||||
if (comps.Length != componentEntries.Count || behaviours.Length != behaviourEntries.Count)
|
|
||||||
{
|
int count = 0;
|
||||||
needRefresh = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
foreach (var comp in comps)
|
foreach (var comp in comps)
|
||||||
{
|
{
|
||||||
|
if (!comp)
|
||||||
|
continue;
|
||||||
|
count++;
|
||||||
if (!compInstanceIDs.Contains(comp.GetInstanceID()))
|
if (!compInstanceIDs.Contains(comp.GetInstanceID()))
|
||||||
{
|
{
|
||||||
needRefresh = true;
|
needRefresh = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!needRefresh)
|
if (!needRefresh)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < behaviours.Length; i++)
|
if (count != componentEntries.Count)
|
||||||
|
needRefresh = true;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
var behaviour = behaviours[i];
|
count = 0;
|
||||||
if (behaviour.enabled != behaviourEnabledStates[i])
|
foreach (var behaviour in behaviours)
|
||||||
|
{
|
||||||
|
if (!behaviour)
|
||||||
|
continue;
|
||||||
|
if (count >= behaviourEnabledStates.Count || behaviour.enabled != behaviourEnabledStates[count])
|
||||||
{
|
{
|
||||||
needRefresh = true;
|
needRefresh = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
count++;
|
||||||
}
|
}
|
||||||
|
if (!needRefresh && count != behaviourEntries.Count)
|
||||||
|
needRefresh = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,9 +188,9 @@ namespace UnityExplorer.UI.Inspectors
|
|||||||
|
|
||||||
componentEntries.Clear();
|
componentEntries.Clear();
|
||||||
compInstanceIDs.Clear();
|
compInstanceIDs.Clear();
|
||||||
|
|
||||||
foreach (var comp in comps)
|
foreach (var comp in comps)
|
||||||
{
|
{
|
||||||
|
if (!comp) continue;
|
||||||
componentEntries.Add(comp);
|
componentEntries.Add(comp);
|
||||||
compInstanceIDs.Add(comp.GetInstanceID());
|
compInstanceIDs.Add(comp.GetInstanceID());
|
||||||
}
|
}
|
||||||
@ -192,6 +199,7 @@ namespace UnityExplorer.UI.Inspectors
|
|||||||
behaviourEnabledStates.Clear();
|
behaviourEnabledStates.Clear();
|
||||||
foreach (var behaviour in behaviours)
|
foreach (var behaviour in behaviours)
|
||||||
{
|
{
|
||||||
|
if (!behaviour) continue;
|
||||||
behaviourEntries.Add(behaviour);
|
behaviourEntries.Add(behaviour);
|
||||||
behaviourEnabledStates.Add(behaviour.enabled);
|
behaviourEnabledStates.Add(behaviour.enabled);
|
||||||
}
|
}
|
||||||
@ -211,7 +219,7 @@ namespace UnityExplorer.UI.Inspectors
|
|||||||
|
|
||||||
private void OnAddComponentClicked(string input)
|
private void OnAddComponentClicked(string input)
|
||||||
{
|
{
|
||||||
if (ReflectionUtility.AllTypes.TryGetValue(input, out Type type))
|
if (ReflectionUtility.GetTypeByName(input) is Type type)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -67,8 +67,12 @@ namespace UnityExplorer.UI.Inspectors
|
|||||||
public void StartInspect(MouseInspectMode mode)
|
public void StartInspect(MouseInspectMode mode)
|
||||||
{
|
{
|
||||||
MainCamera = Camera.main;
|
MainCamera = Camera.main;
|
||||||
if (!MainCamera)
|
|
||||||
|
if (!MainCamera && mode == MouseInspectMode.World)
|
||||||
|
{
|
||||||
|
ExplorerCore.LogWarning("No MainCamera found! Cannot inspect world!");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PanelDragger.ForceEnd();
|
PanelDragger.ForceEnd();
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@ namespace UnityExplorer.UI.Inspectors
|
|||||||
|
|
||||||
private readonly Color disabledButtonColor = new Color(0.24f, 0.24f, 0.24f);
|
private readonly Color disabledButtonColor = new Color(0.24f, 0.24f, 0.24f);
|
||||||
private readonly Color enabledButtonColor = new Color(0.2f, 0.27f, 0.2f);
|
private readonly Color enabledButtonColor = new Color(0.2f, 0.27f, 0.2f);
|
||||||
|
|
||||||
private readonly Dictionary<BindingFlags, ButtonRef> scopeFilterButtons = new Dictionary<BindingFlags, ButtonRef>();
|
private readonly Dictionary<BindingFlags, ButtonRef> scopeFilterButtons = new Dictionary<BindingFlags, ButtonRef>();
|
||||||
private readonly List<Toggle> memberTypeToggles = new List<Toggle>();
|
private readonly List<Toggle> memberTypeToggles = new List<Toggle>();
|
||||||
private InputFieldRef filterInputField;
|
private InputFieldRef filterInputField;
|
||||||
@ -73,7 +74,6 @@ namespace UnityExplorer.UI.Inspectors
|
|||||||
private IEnumerator InitCoroutine()
|
private IEnumerator InitCoroutine()
|
||||||
{
|
{
|
||||||
yield return null;
|
yield return null;
|
||||||
|
|
||||||
LayoutRebuilder.ForceRebuildLayoutImmediate(InspectorPanel.Instance.ContentRect);
|
LayoutRebuilder.ForceRebuildLayoutImmediate(InspectorPanel.Instance.ContentRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,11 +307,8 @@ namespace UnityExplorer.UI.Inspectors
|
|||||||
|
|
||||||
private void CalculateLayouts()
|
private void CalculateLayouts()
|
||||||
{
|
{
|
||||||
// Calculate sizes
|
LeftGroupWidth = (int)Math.Max(200, (0.4f * InspectorManager.PanelWidth) - 5);
|
||||||
LeftGroupWidth = (int)Math.Max(200, (0.4f * InspectorManager.PanelWidth) - 5);// Math.Min(450f, 0.4f * InspectorManager.PanelWidth - 5));
|
|
||||||
RightGroupWidth = (int)Math.Max(200, InspectorManager.PanelWidth - LeftGroupWidth - 65);
|
RightGroupWidth = (int)Math.Max(200, InspectorManager.PanelWidth - LeftGroupWidth - 65);
|
||||||
|
|
||||||
//memberTitleLayout.minWidth = LeftGroupWidth;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetCellLayout(CacheObjectCell cell)
|
private void SetCellLayout(CacheObjectCell cell)
|
||||||
@ -617,12 +614,15 @@ namespace UnityExplorer.UI.Inspectors
|
|||||||
|
|
||||||
// Actual texture viewer
|
// Actual texture viewer
|
||||||
|
|
||||||
var imageObj = UIFactory.CreateUIObject("TextureViewerImage", textureViewer);
|
var imageViewport = UIFactory.CreateVerticalGroup(textureViewer, "Viewport", false, false, true, true);
|
||||||
textureImage = imageObj.AddComponent<Image>();
|
imageViewport.GetComponent<Image>().color = Color.white;
|
||||||
textureImageLayout = textureImage.gameObject.AddComponent<LayoutElement>();
|
imageViewport.AddComponent<Mask>().showMaskGraphic = false;
|
||||||
|
|
||||||
|
var imageObj = UIFactory.CreateUIObject("Image", imageViewport);
|
||||||
var fitter = imageObj.AddComponent<ContentSizeFitter>();
|
var fitter = imageObj.AddComponent<ContentSizeFitter>();
|
||||||
fitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize;
|
fitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize;
|
||||||
|
textureImage = imageObj.AddComponent<Image>();
|
||||||
|
textureImageLayout = UIFactory.SetLayoutElement(imageObj, flexibleWidth: 9999, flexibleHeight: 9999);
|
||||||
|
|
||||||
textureViewer.SetActive(false);
|
textureViewer.SetActive(false);
|
||||||
}
|
}
|
||||||
|
@ -50,8 +50,8 @@ namespace UnityExplorer.UI
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TextGenerator TextGenerator => Component.cachedInputTextGenerator;
|
public TextGenerator TextGenerator => Component.cachedInputTextGenerator;
|
||||||
public bool ReachedMaxVerts => TextGenerator.vertexCount >= UIManager.MAX_TEXT_VERTS;
|
|
||||||
|
|
||||||
|
public bool ReachedMaxVerts => TextGenerator.vertexCount >= UIManager.MAX_TEXT_VERTS;
|
||||||
|
|
||||||
private void OnInputChanged(string value)
|
private void OnInputChanged(string value)
|
||||||
{
|
{
|
||||||
|
@ -76,7 +76,7 @@ namespace UnityExplorer.UI.ObjectExplorer
|
|||||||
lastCheckedTypeInput = desiredTypeInput;
|
lastCheckedTypeInput = desiredTypeInput;
|
||||||
|
|
||||||
//var type = ReflectionUtility.GetTypeByName(desiredTypeInput);
|
//var type = ReflectionUtility.GetTypeByName(desiredTypeInput);
|
||||||
if (ReflectionUtility.AllTypes.TryGetValue(desiredTypeInput, out var cachedType))
|
if (ReflectionUtility.GetTypeByName(desiredTypeInput) is Type cachedType)
|
||||||
{
|
{
|
||||||
var type = cachedType;
|
var type = cachedType;
|
||||||
lastTypeCanHaveGO = typeof(Component).IsAssignableFrom(type) || type == typeof(GameObject);
|
lastTypeCanHaveGO = typeof(Component).IsAssignableFrom(type) || type == typeof(GameObject);
|
||||||
|
@ -15,16 +15,16 @@ namespace UnityExplorer.UI.ObjectExplorer
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static Scene? SelectedScene
|
public static Scene? SelectedScene
|
||||||
{
|
{
|
||||||
get => m_selectedScene;
|
get => selectedScene;
|
||||||
internal set
|
internal set
|
||||||
{
|
{
|
||||||
if (m_selectedScene != null && m_selectedScene == value)
|
if (selectedScene != null && selectedScene == value)
|
||||||
return;
|
return;
|
||||||
m_selectedScene = value;
|
selectedScene = value;
|
||||||
OnInspectedSceneChanged?.Invoke((Scene)m_selectedScene);
|
OnInspectedSceneChanged?.Invoke((Scene)selectedScene);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static Scene? m_selectedScene;
|
private static Scene? selectedScene;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The GameObjects in the currently inspected scene.
|
/// The GameObjects in the currently inspected scene.
|
||||||
@ -62,7 +62,7 @@ namespace UnityExplorer.UI.ObjectExplorer
|
|||||||
public static event Action<ReadOnlyCollection<Scene>> OnLoadedScenesChanged;
|
public static event Action<ReadOnlyCollection<Scene>> OnLoadedScenesChanged;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Equivalent to <see cref="SceneManager.sceneCount"/> + 2, to include 'DontDestroyOnLoad'.
|
/// Equivalent to <see cref="SceneManager.sceneCount"/> + 2, to include 'DontDestroyOnLoad' and the 'None' scene.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static int LoadedSceneCount => SceneManager.sceneCount + 2;
|
public static int LoadedSceneCount => SceneManager.sceneCount + 2;
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -18,10 +19,11 @@ namespace UnityExplorer.UI.Panels
|
|||||||
public override int MinWidth => 750;
|
public override int MinWidth => 750;
|
||||||
public override int MinHeight => 300;
|
public override int MinHeight => 300;
|
||||||
|
|
||||||
public InputFieldScroller InputScroll { get; private set; }
|
public InputFieldScroller InputScroller { get; private set; }
|
||||||
public InputFieldRef Input => InputScroll.InputField;
|
public InputFieldRef Input => InputScroller.InputField;
|
||||||
public Text InputText { get; private set; }
|
public Text InputText { get; private set; }
|
||||||
public Text HighlightText { get; private set; }
|
public Text HighlightText { get; private set; }
|
||||||
|
public Text LineNumberText { get; private set; }
|
||||||
|
|
||||||
public Dropdown HelpDropdown { get; private set; }
|
public Dropdown HelpDropdown { get; private set; }
|
||||||
|
|
||||||
@ -121,19 +123,53 @@ namespace UnityExplorer.UI.Panels
|
|||||||
|
|
||||||
// Console Input
|
// Console Input
|
||||||
|
|
||||||
|
var inputArea = UIFactory.CreateUIObject("InputGroup", content);
|
||||||
|
UIFactory.SetLayoutElement(inputArea, flexibleWidth: 9999, flexibleHeight: 9999);
|
||||||
|
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(inputArea, false, true, true, true);
|
||||||
|
inputArea.AddComponent<Image>().color = Color.white;
|
||||||
|
inputArea.AddComponent<Mask>().showMaskGraphic = false;
|
||||||
|
|
||||||
|
// line numbers
|
||||||
|
|
||||||
|
var linesHolder = UIFactory.CreateUIObject("LinesHolder", inputArea);
|
||||||
|
var linesRect = linesHolder.GetComponent<RectTransform>();
|
||||||
|
linesRect.pivot = new Vector2(0, 1);
|
||||||
|
linesRect.anchorMin = new Vector2(0, 0);
|
||||||
|
linesRect.anchorMax = new Vector2(0, 1);
|
||||||
|
linesRect.sizeDelta = new Vector2(0, 305000);
|
||||||
|
linesRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, 50);
|
||||||
|
linesHolder.AddComponent<Image>().color = new Color(0.05f, 0.05f, 0.05f);
|
||||||
|
UIFactory.SetLayoutGroup<VerticalLayoutGroup>(linesHolder, true, true, true, true);
|
||||||
|
|
||||||
|
LineNumberText = UIFactory.CreateLabel(linesHolder, "LineNumbers", "1", TextAnchor.UpperCenter, Color.grey, fontSize: 16);
|
||||||
|
LineNumberText.font = UIManager.ConsoleFont;
|
||||||
|
|
||||||
|
// input field
|
||||||
|
|
||||||
int fontSize = 16;
|
int fontSize = 16;
|
||||||
|
|
||||||
var inputObj = UIFactory.CreateScrollInputField(this.content, "ConsoleInput", ConsoleController.STARTUP_TEXT, out var inputScroller, fontSize);
|
var inputObj = UIFactory.CreateScrollInputField(inputArea, "ConsoleInput", ConsoleController.STARTUP_TEXT,
|
||||||
InputScroll = inputScroller;
|
out var inputScroller, fontSize);
|
||||||
|
InputScroller = inputScroller;
|
||||||
ConsoleController.defaultInputFieldAlpha = Input.Component.selectionColor.a;
|
ConsoleController.defaultInputFieldAlpha = Input.Component.selectionColor.a;
|
||||||
Input.OnValueChanged += InvokeOnValueChanged;
|
Input.OnValueChanged += InvokeOnValueChanged;
|
||||||
|
|
||||||
|
// move line number text with input field
|
||||||
|
linesRect.transform.SetParent(inputObj.transform.Find("Viewport"), false);
|
||||||
|
inputScroller.Slider.Scrollbar.onValueChanged.AddListener((float val) => { SetLinesPosition(); });
|
||||||
|
inputScroller.Slider.Slider.onValueChanged.AddListener((float val) => { SetLinesPosition(); });
|
||||||
|
void SetLinesPosition()
|
||||||
|
{
|
||||||
|
linesRect.anchoredPosition = new Vector2(linesRect.anchoredPosition.x, inputScroller.ContentRect.anchoredPosition.y);
|
||||||
|
//SetInputLayout();
|
||||||
|
}
|
||||||
|
|
||||||
InputText = Input.Component.textComponent;
|
InputText = Input.Component.textComponent;
|
||||||
InputText.supportRichText = false;
|
InputText.supportRichText = false;
|
||||||
Input.PlaceholderText.fontSize = fontSize;
|
|
||||||
InputText.color = Color.clear;
|
InputText.color = Color.clear;
|
||||||
Input.Component.customCaretColor = true;
|
Input.Component.customCaretColor = true;
|
||||||
Input.Component.caretColor = Color.white;
|
Input.Component.caretColor = Color.white;
|
||||||
|
Input.PlaceholderText.fontSize = fontSize;
|
||||||
|
|
||||||
// Lexer highlight text overlay
|
// Lexer highlight text overlay
|
||||||
var highlightTextObj = UIFactory.CreateUIObject("HighlightText", InputText.gameObject);
|
var highlightTextObj = UIFactory.CreateUIObject("HighlightText", InputText.gameObject);
|
||||||
@ -154,7 +190,19 @@ namespace UnityExplorer.UI.Panels
|
|||||||
Input.PlaceholderText.font = UIManager.ConsoleFont;
|
Input.PlaceholderText.font = UIManager.ConsoleFont;
|
||||||
HighlightText.font = UIManager.ConsoleFont;
|
HighlightText.font = UIManager.ConsoleFont;
|
||||||
|
|
||||||
|
RuntimeProvider.Instance.StartCoroutine(DelayedLayoutSetup());
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerator DelayedLayoutSetup()
|
||||||
|
{
|
||||||
|
yield return null;
|
||||||
|
SetInputLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetInputLayout()
|
||||||
|
{
|
||||||
|
Input.Rect.offsetMin = new Vector2(52, Input.Rect.offsetMin.y);
|
||||||
|
Input.Rect.offsetMax = new Vector2(2, Input.Rect.offsetMax.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.Core.Input;
|
using UnityExplorer.Core.Input;
|
||||||
using System.IO;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using UnityExplorer.UI.Models;
|
using UnityExplorer.UI.Models;
|
||||||
using System.Linq;
|
|
||||||
using UnityExplorer.UI.Widgets.AutoComplete;
|
using UnityExplorer.UI.Widgets.AutoComplete;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.Panels
|
namespace UnityExplorer.UI.Panels
|
||||||
|
@ -154,14 +154,13 @@ namespace UnityExplorer.UI.Panels
|
|||||||
// Prevent panel going oustide screen bounds
|
// Prevent panel going oustide screen bounds
|
||||||
var halfW = Screen.width * 0.5f;
|
var halfW = Screen.width * 0.5f;
|
||||||
var halfH = Screen.height * 0.5f;
|
var halfH = Screen.height * 0.5f;
|
||||||
pos.x = Math.Max(-halfW, Math.Min(pos.x, halfW - panel.rect.width));
|
|
||||||
pos.y = Math.Max(-halfH + panel.rect.height, Math.Min(pos.y, halfH));
|
pos.x = Math.Max(-halfW - panel.rect.width + 50, Math.Min(pos.x, halfW - 50));
|
||||||
|
pos.y = Math.Max(-halfH + 50, Math.Min(pos.y, halfH));
|
||||||
|
|
||||||
panel.localPosition = pos;
|
panel.localPosition = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region Save Data
|
#region Save Data
|
||||||
|
|
||||||
public abstract void DoSaveToConfigElement();
|
public abstract void DoSaveToConfigElement();
|
||||||
|
@ -409,56 +409,49 @@ namespace UnityExplorer.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a Toggle control.
|
/// Create a Toggle control.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static GameObject CreateToggle(GameObject parent, string name, out Toggle toggle, out Text text, Color bgColor = default)
|
public static GameObject CreateToggle(GameObject parent, string name, out Toggle toggle, out Text text, Color bgColor = default,
|
||||||
|
int checkWidth = 20, int checkHeight = 20)
|
||||||
{
|
{
|
||||||
|
// Main obj
|
||||||
GameObject toggleObj = CreateUIObject(name, parent, _smallElementSize);
|
GameObject toggleObj = CreateUIObject(name, parent, _smallElementSize);
|
||||||
|
SetLayoutGroup<HorizontalLayoutGroup>(toggleObj, false, false, true, true, 5, 0,0,0,0, childAlignment: TextAnchor.MiddleLeft);
|
||||||
GameObject bgObj = CreateUIObject("Background", toggleObj);
|
|
||||||
GameObject checkObj = CreateUIObject("Checkmark", bgObj);
|
|
||||||
GameObject labelObj = CreateUIObject("Label", toggleObj);
|
|
||||||
|
|
||||||
toggle = toggleObj.AddComponent<Toggle>();
|
toggle = toggleObj.AddComponent<Toggle>();
|
||||||
toggle.isOn = true;
|
toggle.isOn = true;
|
||||||
|
SetDefaultSelectableColors(toggle);
|
||||||
|
// need a second reference so we can use it inside the lambda, since 'toggle' is an out var.
|
||||||
|
Toggle t2 = toggle;
|
||||||
|
toggle.onValueChanged.AddListener((bool _) => { t2.OnDeselect(null); });
|
||||||
|
|
||||||
// second reference so we can use it inside the lambda, 'toggle' is an out var.
|
// Check mark background
|
||||||
Toggle toggleComp = toggle;
|
|
||||||
toggle.onValueChanged.AddListener(Deselect);
|
|
||||||
void Deselect(bool _)
|
|
||||||
{
|
|
||||||
toggleComp.OnDeselect(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
Image bgImage = bgObj.AddComponent<Image>();
|
GameObject checkBgObj = CreateUIObject("Background", toggleObj);
|
||||||
|
Image bgImage = checkBgObj.AddComponent<Image>();
|
||||||
bgImage.color = bgColor == default ? new Color(0.04f, 0.04f, 0.04f, 0.75f) : bgColor;
|
bgImage.color = bgColor == default ? new Color(0.04f, 0.04f, 0.04f, 0.75f) : bgColor;
|
||||||
|
|
||||||
Image checkImage = checkObj.AddComponent<Image>();
|
SetLayoutGroup<HorizontalLayoutGroup>(checkBgObj, true, true, true, true, 0, 2, 2, 2, 2);
|
||||||
|
SetLayoutElement(checkBgObj, minWidth: checkWidth, flexibleWidth: 0, minHeight: checkHeight, flexibleHeight: 0);
|
||||||
|
|
||||||
|
// Check mark image
|
||||||
|
|
||||||
|
GameObject checkMarkObj = CreateUIObject("Checkmark", checkBgObj);
|
||||||
|
Image checkImage = checkMarkObj.AddComponent<Image>();
|
||||||
checkImage.color = new Color(0.8f, 1, 0.8f, 0.3f);
|
checkImage.color = new Color(0.8f, 1, 0.8f, 0.3f);
|
||||||
|
|
||||||
|
// Label
|
||||||
|
|
||||||
|
GameObject labelObj = CreateUIObject("Label", toggleObj);
|
||||||
text = labelObj.AddComponent<Text>();
|
text = labelObj.AddComponent<Text>();
|
||||||
text.text = "Toggle";
|
text.text = "";
|
||||||
|
text.alignment = TextAnchor.MiddleLeft;
|
||||||
SetDefaultTextValues(text);
|
SetDefaultTextValues(text);
|
||||||
|
|
||||||
|
SetLayoutElement(labelObj, minWidth: 0, flexibleWidth: 0, minHeight: checkHeight, flexibleHeight: 0);
|
||||||
|
|
||||||
|
// References
|
||||||
|
|
||||||
toggle.graphic = checkImage;
|
toggle.graphic = checkImage;
|
||||||
toggle.targetGraphic = bgImage;
|
toggle.targetGraphic = bgImage;
|
||||||
SetDefaultSelectableColors(toggle);
|
|
||||||
|
|
||||||
RectTransform bgRect = bgObj.GetComponent<RectTransform>();
|
|
||||||
bgRect.anchorMin = new Vector2(0f, 1f);
|
|
||||||
bgRect.anchorMax = new Vector2(0f, 1f);
|
|
||||||
bgRect.anchoredPosition = new Vector2(13f, -13f);
|
|
||||||
bgRect.sizeDelta = new Vector2(20f, 20f);
|
|
||||||
|
|
||||||
RectTransform checkRect = checkObj.GetComponent<RectTransform>();
|
|
||||||
checkRect.anchorMin = new Vector2(0.5f, 0.5f);
|
|
||||||
checkRect.anchorMax = new Vector2(0.5f, 0.5f);
|
|
||||||
checkRect.anchoredPosition = Vector2.zero;
|
|
||||||
checkRect.sizeDelta = new Vector2(14f, 14f);
|
|
||||||
|
|
||||||
RectTransform labelRect = labelObj.GetComponent<RectTransform>();
|
|
||||||
labelRect.anchorMin = new Vector2(0f, 0f);
|
|
||||||
labelRect.anchorMax = new Vector2(1f, 1f);
|
|
||||||
labelRect.offsetMin = new Vector2(28f, 2f);
|
|
||||||
labelRect.offsetMax = new Vector2(-5f, -5f);
|
|
||||||
return toggleObj;
|
return toggleObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,6 +164,22 @@ namespace UnityExplorer.UI
|
|||||||
InputFieldRef.UpdateInstances();
|
InputFieldRef.UpdateInstances();
|
||||||
UIBehaviourModel.UpdateInstances();
|
UIBehaviourModel.UpdateInstances();
|
||||||
|
|
||||||
|
// update the timescale value
|
||||||
|
if (!timeInput.Component.isFocused && lastTimeScale != Time.timeScale)
|
||||||
|
{
|
||||||
|
if (pauseButtonPausing && Time.timeScale != 0.0f)
|
||||||
|
{
|
||||||
|
pauseButtonPausing = false;
|
||||||
|
OnPauseButtonToggled();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pauseButtonPausing)
|
||||||
|
{
|
||||||
|
timeInput.Text = Time.timeScale.ToString("F2");
|
||||||
|
lastTimeScale = Time.timeScale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// check screen dimension change
|
// check screen dimension change
|
||||||
if (Screen.width != lastScreenWidth || Screen.height != lastScreenHeight)
|
if (Screen.width != lastScreenWidth || Screen.height != lastScreenHeight)
|
||||||
OnScreenDimensionsChanged();
|
OnScreenDimensionsChanged();
|
||||||
@ -274,13 +290,14 @@ namespace UnityExplorer.UI
|
|||||||
{
|
{
|
||||||
pauseButtonPausing = !pauseButtonPausing;
|
pauseButtonPausing = !pauseButtonPausing;
|
||||||
|
|
||||||
if (pauseButtonPausing)
|
Time.timeScale = pauseButtonPausing ? 0f : lastTimeScale;
|
||||||
lastTimeScale = Time.timeScale;
|
|
||||||
|
|
||||||
float scale = pauseButtonPausing ? 0f : lastTimeScale;
|
OnPauseButtonToggled();
|
||||||
Time.timeScale = scale;
|
}
|
||||||
|
|
||||||
timeInput.Component.text = scale.ToString("F2");
|
private static void OnPauseButtonToggled()
|
||||||
|
{
|
||||||
|
timeInput.Component.text = Time.timeScale.ToString("F2");
|
||||||
timeInput.Component.readOnly = pauseButtonPausing;
|
timeInput.Component.readOnly = pauseButtonPausing;
|
||||||
timeInput.Component.textComponent.color = pauseButtonPausing ? Color.grey : Color.white;
|
timeInput.Component.textComponent.color = pauseButtonPausing ? Color.grey : Color.white;
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for exact match first
|
// Check for exact match first
|
||||||
if (ReflectionUtility.AllTypes.TryGetValue(value, out Type t) && allowedTypes.Contains(t))
|
if (ReflectionUtility.GetTypeByName(value) is Type t && allowedTypes.Contains(t))
|
||||||
AddSuggestion(t);
|
AddSuggestion(t);
|
||||||
|
|
||||||
foreach (var entry in allowedTypes)
|
foreach (var entry in allowedTypes)
|
||||||
|
@ -4,9 +4,9 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
|
||||||
using UnityEngine.EventSystems;
|
|
||||||
using UnityEngine.Events;
|
using UnityEngine.Events;
|
||||||
|
using UnityEngine.EventSystems;
|
||||||
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.UI.Models;
|
using UnityExplorer.UI.Models;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.Widgets
|
namespace UnityExplorer.UI.Widgets
|
||||||
@ -80,12 +80,12 @@ namespace UnityExplorer.UI.Widgets
|
|||||||
|
|
||||||
if (ContentRect.rect.height < desiredHeight)
|
if (ContentRect.rect.height < desiredHeight)
|
||||||
{
|
{
|
||||||
ContentRect.sizeDelta = new Vector2(0, desiredHeight);
|
ContentRect.sizeDelta = new Vector2(ContentRect.sizeDelta.x, desiredHeight);
|
||||||
this.Slider.UpdateSliderHandle();
|
this.Slider.UpdateSliderHandle();
|
||||||
}
|
}
|
||||||
else if (ContentRect.rect.height > desiredHeight)
|
else if (ContentRect.rect.height > desiredHeight)
|
||||||
{
|
{
|
||||||
ContentRect.sizeDelta = new Vector2(0, desiredHeight);
|
ContentRect.sizeDelta = new Vector2(ContentRect.sizeDelta.x, desiredHeight);
|
||||||
this.Slider.UpdateSliderHandle();
|
this.Slider.UpdateSliderHandle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ namespace UnityExplorer.UI.Widgets
|
|||||||
private bool m_enabled;
|
private bool m_enabled;
|
||||||
|
|
||||||
public Action<CachedTransform> OnExpandToggled;
|
public Action<CachedTransform> OnExpandToggled;
|
||||||
|
public Action<CachedTransform> OnEnableToggled;
|
||||||
public Action<GameObject> OnGameObjectClicked;
|
public Action<GameObject> OnGameObjectClicked;
|
||||||
|
|
||||||
public CachedTransform cachedTransform;
|
public CachedTransform cachedTransform;
|
||||||
@ -27,15 +28,20 @@ namespace UnityExplorer.UI.Widgets
|
|||||||
|
|
||||||
public ButtonRef ExpandButton;
|
public ButtonRef ExpandButton;
|
||||||
public ButtonRef NameButton;
|
public ButtonRef NameButton;
|
||||||
|
public Toggle EnabledToggle;
|
||||||
|
|
||||||
public LayoutElement spacer;
|
public LayoutElement spacer;
|
||||||
|
|
||||||
public void OnMainButtonClicked()
|
public void Enable()
|
||||||
{
|
{
|
||||||
if (cachedTransform.Value)
|
m_enabled = true;
|
||||||
OnGameObjectClicked?.Invoke(cachedTransform.Value.gameObject);
|
UIRoot.SetActive(true);
|
||||||
else
|
}
|
||||||
ExplorerCore.LogWarning("The object was destroyed!");
|
|
||||||
|
public void Disable()
|
||||||
|
{
|
||||||
|
m_enabled = false;
|
||||||
|
UIRoot.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ConfigureCell(CachedTransform cached, int cellIndex)
|
public void ConfigureCell(CachedTransform cached, int cellIndex)
|
||||||
@ -59,6 +65,8 @@ namespace UnityExplorer.UI.Widgets
|
|||||||
NameButton.ButtonText.text = cached.Value.name;
|
NameButton.ButtonText.text = cached.Value.name;
|
||||||
NameButton.ButtonText.color = cached.Value.gameObject.activeSelf ? Color.white : Color.grey;
|
NameButton.ButtonText.color = cached.Value.gameObject.activeSelf ? Color.white : Color.grey;
|
||||||
|
|
||||||
|
EnabledToggle.Set(cached.Value.gameObject.activeSelf, false);
|
||||||
|
|
||||||
int childCount = cached.Value.childCount;
|
int childCount = cached.Value.childCount;
|
||||||
if (childCount > 0)
|
if (childCount > 0)
|
||||||
{
|
{
|
||||||
@ -82,16 +90,12 @@ namespace UnityExplorer.UI.Widgets
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Disable()
|
public void OnMainButtonClicked()
|
||||||
{
|
{
|
||||||
m_enabled = false;
|
if (cachedTransform.Value)
|
||||||
UIRoot.SetActive(false);
|
OnGameObjectClicked?.Invoke(cachedTransform.Value.gameObject);
|
||||||
}
|
else
|
||||||
|
ExplorerCore.LogWarning("The object was destroyed!");
|
||||||
public void Enable()
|
|
||||||
{
|
|
||||||
m_enabled = true;
|
|
||||||
UIRoot.SetActive(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnExpandClicked()
|
public void OnExpandClicked()
|
||||||
@ -99,10 +103,15 @@ namespace UnityExplorer.UI.Widgets
|
|||||||
OnExpandToggled?.Invoke(cachedTransform);
|
OnExpandToggled?.Invoke(cachedTransform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnEnableClicked(bool value)
|
||||||
|
{
|
||||||
|
OnEnableToggled?.Invoke(cachedTransform);
|
||||||
|
}
|
||||||
|
|
||||||
public GameObject CreateContent(GameObject parent)
|
public GameObject CreateContent(GameObject parent)
|
||||||
{
|
{
|
||||||
UIRoot = UIFactory.CreateUIObject("TransformCell", parent);
|
UIRoot = UIFactory.CreateUIObject("TransformCell", parent);
|
||||||
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(UIRoot, true, true, true, true, 2, childAlignment: TextAnchor.MiddleCenter);
|
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(UIRoot, false, false, true, true, 2, childAlignment: TextAnchor.MiddleCenter);
|
||||||
Rect = UIRoot.GetComponent<RectTransform>();
|
Rect = UIRoot.GetComponent<RectTransform>();
|
||||||
Rect.anchorMin = new Vector2(0, 1);
|
Rect.anchorMin = new Vector2(0, 1);
|
||||||
Rect.anchorMax = new Vector2(0, 1);
|
Rect.anchorMax = new Vector2(0, 1);
|
||||||
@ -114,9 +123,19 @@ namespace UnityExplorer.UI.Widgets
|
|||||||
UIFactory.SetLayoutElement(spacerObj, minWidth: 0, flexibleWidth: 0, minHeight: 0, flexibleHeight: 0);
|
UIFactory.SetLayoutElement(spacerObj, minWidth: 0, flexibleWidth: 0, minHeight: 0, flexibleHeight: 0);
|
||||||
this.spacer = spacerObj.GetComponent<LayoutElement>();
|
this.spacer = spacerObj.GetComponent<LayoutElement>();
|
||||||
|
|
||||||
|
// Expand arrow
|
||||||
|
|
||||||
ExpandButton = UIFactory.CreateButton(this.UIRoot, "ExpandButton", "►");
|
ExpandButton = UIFactory.CreateButton(this.UIRoot, "ExpandButton", "►");
|
||||||
UIFactory.SetLayoutElement(ExpandButton.Component.gameObject, minWidth: 15, flexibleWidth: 0, minHeight: 25, flexibleHeight: 0);
|
UIFactory.SetLayoutElement(ExpandButton.Component.gameObject, minWidth: 15, flexibleWidth: 0, minHeight: 25, flexibleHeight: 0);
|
||||||
|
|
||||||
|
// Enabled toggle
|
||||||
|
|
||||||
|
var toggleObj = UIFactory.CreateToggle(UIRoot, "BehaviourToggle", out EnabledToggle, out var behavText, default, 17, 17);
|
||||||
|
UIFactory.SetLayoutElement(toggleObj, minHeight: 17, flexibleHeight: 0, minWidth: 17);
|
||||||
|
EnabledToggle.onValueChanged.AddListener(OnEnableClicked);
|
||||||
|
|
||||||
|
// Name button
|
||||||
|
|
||||||
NameButton = UIFactory.CreateButton(this.UIRoot, "NameButton", "Name", null);
|
NameButton = UIFactory.CreateButton(this.UIRoot, "NameButton", "Name", null);
|
||||||
UIFactory.SetLayoutElement(NameButton.Component.gameObject, flexibleWidth: 9999, minHeight: 25, flexibleHeight: 0);
|
UIFactory.SetLayoutElement(NameButton.Component.gameObject, flexibleWidth: 9999, minHeight: 25, flexibleHeight: 0);
|
||||||
var nameLabel = NameButton.Component.GetComponentInChildren<Text>();
|
var nameLabel = NameButton.Component.GetComponentInChildren<Text>();
|
||||||
|
@ -60,8 +60,9 @@ namespace UnityExplorer.UI.Widgets
|
|||||||
|
|
||||||
public void OnCellBorrowed(TransformCell cell)
|
public void OnCellBorrowed(TransformCell cell)
|
||||||
{
|
{
|
||||||
cell.OnExpandToggled += ToggleExpandCell;
|
cell.OnExpandToggled += OnCellExpandToggled;
|
||||||
cell.OnGameObjectClicked += OnGameObjectClicked;
|
cell.OnGameObjectClicked += OnGameObjectClicked;
|
||||||
|
cell.OnEnableToggled += OnCellEnableToggled;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnGameObjectClicked(GameObject obj)
|
private void OnGameObjectClicked(GameObject obj)
|
||||||
@ -72,6 +73,24 @@ namespace UnityExplorer.UI.Widgets
|
|||||||
InspectorManager.Inspect(obj);
|
InspectorManager.Inspect(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OnCellExpandToggled(CachedTransform cache)
|
||||||
|
{
|
||||||
|
var instanceID = cache.InstanceID;
|
||||||
|
if (expandedInstanceIDs.Contains(instanceID))
|
||||||
|
expandedInstanceIDs.Remove(instanceID);
|
||||||
|
else
|
||||||
|
expandedInstanceIDs.Add(instanceID);
|
||||||
|
|
||||||
|
RefreshData(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnCellEnableToggled(CachedTransform cache)
|
||||||
|
{
|
||||||
|
cache.Value.gameObject.SetActive(!cache.Value.gameObject.activeSelf);
|
||||||
|
|
||||||
|
RefreshData(true);
|
||||||
|
}
|
||||||
|
|
||||||
public void Init()
|
public void Init()
|
||||||
{
|
{
|
||||||
ScrollPool.Initialize(this);
|
ScrollPool.Initialize(this);
|
||||||
@ -261,16 +280,5 @@ namespace UnityExplorer.UI.Widgets
|
|||||||
else
|
else
|
||||||
cell.Disable();
|
cell.Disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ToggleExpandCell(CachedTransform cache)
|
|
||||||
{
|
|
||||||
var instanceID = cache.InstanceID;
|
|
||||||
if (expandedInstanceIDs.Contains(instanceID))
|
|
||||||
expandedInstanceIDs.Remove(instanceID);
|
|
||||||
else
|
|
||||||
expandedInstanceIDs.Add(instanceID);
|
|
||||||
|
|
||||||
RefreshData(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@
|
|||||||
<!-- BepInEx universal refs -->
|
<!-- BepInEx universal refs -->
|
||||||
<ItemGroup Condition="'$(IsBepInEx)'=='true'">
|
<ItemGroup Condition="'$(IsBepInEx)'=='true'">
|
||||||
<Reference Include="0Harmony">
|
<Reference Include="0Harmony">
|
||||||
<HintPath>..\lib\HarmonyX\Harmony\bin\Release\net35\0Harmony.dll</HintPath>
|
<HintPath>packages\HarmonyX.2.4.2\lib\net35\0Harmony.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@ -181,7 +181,7 @@
|
|||||||
<!-- Standalone refs -->
|
<!-- Standalone refs -->
|
||||||
<ItemGroup Condition="'$(IsStandalone)'=='true'">
|
<ItemGroup Condition="'$(IsStandalone)'=='true'">
|
||||||
<Reference Include="0Harmony">
|
<Reference Include="0Harmony">
|
||||||
<HintPath>..\lib\HarmonyX\Harmony\bin\Release\net35\0Harmony.dll</HintPath>
|
<HintPath>packages\HarmonyX.2.4.2\lib\net35\0Harmony.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@ -366,11 +366,11 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup />
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<Import Project="packages\ILRepack.Lib.MSBuild.Task.2.0.18.1\build\ILRepack.Lib.MSBuild.Task.targets" Condition="Exists('packages\ILRepack.Lib.MSBuild.Task.2.0.18.1\build\ILRepack.Lib.MSBuild.Task.targets')" />
|
<Import Project="packages\ILRepack.Lib.MSBuild.Task.2.0.18.2\build\ILRepack.Lib.MSBuild.Task.targets" Condition="Exists('packages\ILRepack.Lib.MSBuild.Task.2.0.18.2\build\ILRepack.Lib.MSBuild.Task.targets')" />
|
||||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Error Condition="!Exists('packages\ILRepack.Lib.MSBuild.Task.2.0.18.1\build\ILRepack.Lib.MSBuild.Task.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\ILRepack.Lib.MSBuild.Task.2.0.18.1\build\ILRepack.Lib.MSBuild.Task.targets'))" />
|
<Error Condition="!Exists('packages\ILRepack.Lib.MSBuild.Task.2.0.18.2\build\ILRepack.Lib.MSBuild.Task.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\ILRepack.Lib.MSBuild.Task.2.0.18.2\build\ILRepack.Lib.MSBuild.Task.targets'))" />
|
||||||
</Target>
|
</Target>
|
||||||
</Project>
|
</Project>
|
@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 16
|
# Visual Studio Version 16
|
||||||
VisualStudioVersion = 16.0.30128.74
|
VisualStudioVersion = 16.0.30128.74
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Harmony", "..\lib\HarmonyX\Harmony\Harmony.csproj", "{F2D7872C-5D4D-49EB-A656-C3D496DB4204}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnhollowerBaseLib", "..\lib\Il2CppAssemblyUnhollower\UnhollowerBaseLib\UnhollowerBaseLib.csproj", "{7B7E5024-385D-4A46-9196-A6AF8F7FBDD5}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnhollowerBaseLib", "..\lib\Il2CppAssemblyUnhollower\UnhollowerBaseLib\UnhollowerBaseLib.csproj", "{7B7E5024-385D-4A46-9196-A6AF8F7FBDD5}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mcs", "..\lib\mcs-unity\mcs\mcs.csproj", "{E4989E4C-0875-4528-9031-08E2C0E70103}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mcs", "..\lib\mcs-unity\mcs\mcs.csproj", "{E4989E4C-0875-4528-9031-08E2C0E70103}"
|
||||||
@ -24,24 +22,6 @@ Global
|
|||||||
Release_STANDALONE_Mono|Any CPU = Release_STANDALONE_Mono|Any CPU
|
Release_STANDALONE_Mono|Any CPU = Release_STANDALONE_Mono|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{F2D7872C-5D4D-49EB-A656-C3D496DB4204}.Release_BIE_Cpp|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{F2D7872C-5D4D-49EB-A656-C3D496DB4204}.Release_BIE_Cpp|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{F2D7872C-5D4D-49EB-A656-C3D496DB4204}.Release_BIE5_Mono|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{F2D7872C-5D4D-49EB-A656-C3D496DB4204}.Release_BIE5_Mono|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{F2D7872C-5D4D-49EB-A656-C3D496DB4204}.Release_BIE6_Mono|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{F2D7872C-5D4D-49EB-A656-C3D496DB4204}.Release_BIE6_Mono|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{F2D7872C-5D4D-49EB-A656-C3D496DB4204}.Release_ML_Cpp|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{F2D7872C-5D4D-49EB-A656-C3D496DB4204}.Release_ML_Cpp|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{F2D7872C-5D4D-49EB-A656-C3D496DB4204}.Release_ML_Mono|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{F2D7872C-5D4D-49EB-A656-C3D496DB4204}.Release_ML_Mono|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{F2D7872C-5D4D-49EB-A656-C3D496DB4204}.Release_MLLegacy_Cpp|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{F2D7872C-5D4D-49EB-A656-C3D496DB4204}.Release_MLLegacy_Cpp|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{F2D7872C-5D4D-49EB-A656-C3D496DB4204}.Release_MLLegacy_Mono|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{F2D7872C-5D4D-49EB-A656-C3D496DB4204}.Release_MLLegacy_Mono|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{F2D7872C-5D4D-49EB-A656-C3D496DB4204}.Release_STANDALONE_Cpp|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{F2D7872C-5D4D-49EB-A656-C3D496DB4204}.Release_STANDALONE_Cpp|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{F2D7872C-5D4D-49EB-A656-C3D496DB4204}.Release_STANDALONE_Mono|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{F2D7872C-5D4D-49EB-A656-C3D496DB4204}.Release_STANDALONE_Mono|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{7B7E5024-385D-4A46-9196-A6AF8F7FBDD5}.Release_BIE_Cpp|Any CPU.ActiveCfg = Release|Any CPU
|
{7B7E5024-385D-4A46-9196-A6AF8F7FBDD5}.Release_BIE_Cpp|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{7B7E5024-385D-4A46-9196-A6AF8F7FBDD5}.Release_BIE_Cpp|Any CPU.Build.0 = Release|Any CPU
|
{7B7E5024-385D-4A46-9196-A6AF8F7FBDD5}.Release_BIE_Cpp|Any CPU.Build.0 = Release|Any CPU
|
||||||
{7B7E5024-385D-4A46-9196-A6AF8F7FBDD5}.Release_BIE5_Mono|Any CPU.ActiveCfg = Release|Any CPU
|
{7B7E5024-385D-4A46-9196-A6AF8F7FBDD5}.Release_BIE5_Mono|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="ILRepack.Lib.MSBuild.Task" version="2.0.18.1" targetFramework="net472" />
|
<package id="HarmonyX" version="2.4.2" targetFramework="net35" />
|
||||||
|
<package id="ILRepack.Lib.MSBuild.Task" version="2.0.18.2" targetFramework="net35" />
|
||||||
<package id="ini-parser" version="2.5.2" targetFramework="net35" />
|
<package id="ini-parser" version="2.5.2" targetFramework="net35" />
|
||||||
|
<package id="Mono.Cecil" version="0.10.4" targetFramework="net35" />
|
||||||
</packages>
|
</packages>
|
Reference in New Issue
Block a user