mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-23 17:02:36 +08:00
Compare commits
91 Commits
Author | SHA1 | Date | |
---|---|---|---|
5c9dcb1d43 | |||
602770d980 | |||
f26371f95f | |||
a673c39f4a | |||
40583cae3d | |||
20018a9ba9 | |||
dabf92a1a5 | |||
b7e275f02c | |||
f393e0d706 | |||
ab8acc9e84 | |||
66c30ee70e | |||
ddd271c00d | |||
30fe9e4dde | |||
fa3a436037 | |||
ca27d2b20f | |||
4315e0c547 | |||
3e19e74329 | |||
5a3ffebadc | |||
6e6b6239d8 | |||
03c8e5a8bd | |||
44f7209843 | |||
734e45cf9f | |||
97838e0b3a | |||
304b47f898 | |||
3d1fcbcd9f | |||
36fc17aa43 | |||
adfa29e63c | |||
3ffdcea73b | |||
dfd55260a8 | |||
29c78dc5a6 | |||
bf59d9d6cd | |||
bb0c59534a | |||
802bb722bc | |||
9ca992b0d7 | |||
5f3b3a6870 | |||
f5bce439cb | |||
e2b2c9038a | |||
fbefccd6b7 | |||
271c91f0d0 | |||
eb221bd868 | |||
5b516eb4cc | |||
601567f9d2 | |||
7ff508b874 | |||
09a7cd35cf | |||
db4a338d26 | |||
c08e02057c | |||
362fcdc51a | |||
73bd172e4d | |||
454d3bd0b4 | |||
f815a13d9a | |||
65c4d49274 | |||
d99137526e | |||
92447b55cd | |||
87d5d5a2de | |||
08cff3386b | |||
6033200579 | |||
94ec1c4908 | |||
7a400e762c | |||
67f9f744bb | |||
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 |
60
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
Normal file
60
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
name: Bug Report
|
||||||
|
description: File a bug or crash report
|
||||||
|
title: "[Bug]: "
|
||||||
|
labels: [bug]
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
Thanks for submitting a bug report, please fill out as much detail as possible.
|
||||||
|
- type: checkboxes
|
||||||
|
id: latestversion
|
||||||
|
attributes:
|
||||||
|
label: Are you on the latest version of UnityExplorer?
|
||||||
|
description: If not, you must update first.
|
||||||
|
options:
|
||||||
|
- label: Yes, I'm on the latest version of UnityExplorer.
|
||||||
|
required: true
|
||||||
|
- type: dropdown
|
||||||
|
id: version
|
||||||
|
attributes:
|
||||||
|
label: Which release are you using?
|
||||||
|
description: Please select your environment for UnityExplorer.
|
||||||
|
options:
|
||||||
|
- BepInEx IL2CPP
|
||||||
|
- BepInEx 6.X Mono
|
||||||
|
- BepInEx 5.X Mono
|
||||||
|
- MelonLoader IL2CPP
|
||||||
|
- MelonLoader Mono
|
||||||
|
- Standalone IL2CPP
|
||||||
|
- Standalone Mono
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: game
|
||||||
|
attributes:
|
||||||
|
label: Which game did this occur on?
|
||||||
|
description: Please tell us the name of the game. If it's a personal or private project, just let us know the Unity version.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: what-happened
|
||||||
|
attributes:
|
||||||
|
label: Describe the issue.
|
||||||
|
description: What happened? Should something else have happened instead? Please provide steps to reproduce the issue if possible.
|
||||||
|
placeholder: Tell us what you see!
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: logs
|
||||||
|
attributes:
|
||||||
|
label: Relevant log output
|
||||||
|
description: |
|
||||||
|
Please copy and paste any relevant logs and stack traces.
|
||||||
|
* Unity log: `%userprofile%\AppData\LocalLow\{Company}\{Game}\Player.log` or `output_log.txt`
|
||||||
|
* BepInEx: `BepInEx\LogOutput.log`
|
||||||
|
* MelonLoader: `MelonLoader\latest.log`
|
||||||
|
* Standalone: `{DLL_Location}\UnityExplorer\Logs\` (pick the most recent one)
|
||||||
|
render: shell
|
||||||
|
validations:
|
||||||
|
required: false
|
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
blank_issues_enabled: false
|
18
.github/ISSUE_TEMPLATE/enhancement.yaml
vendored
Normal file
18
.github/ISSUE_TEMPLATE/enhancement.yaml
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
name: New feature or enhancement
|
||||||
|
description: Suggest or discuss a feature or enhancement for UnityExplorer
|
||||||
|
title: "[Enhancement]: "
|
||||||
|
labels: [enhancement]
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
Thanks for taking the time to discuss UnityExplorer, please provide as much detail as possible.
|
||||||
|
- type: textarea
|
||||||
|
id: description
|
||||||
|
attributes:
|
||||||
|
label: Describe the new feature or enhancement
|
||||||
|
description: |
|
||||||
|
Please go into as much detail as necessary in describing the new feature or enhancement.
|
||||||
|
If providing examples or suggestions for the required C# code, please use syntax-highlighted code blocks.
|
||||||
|
validations:
|
||||||
|
required: true
|
13
.github/ISSUE_TEMPLATE/other.yaml
vendored
Normal file
13
.github/ISSUE_TEMPLATE/other.yaml
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
name: Other
|
||||||
|
description: Something else?
|
||||||
|
title: "[Other]: "
|
||||||
|
labels: [Other]
|
||||||
|
body:
|
||||||
|
- type: textarea
|
||||||
|
id: description
|
||||||
|
attributes:
|
||||||
|
label: Describe the issue
|
||||||
|
description: |
|
||||||
|
Please describe the issue in as much detail as possible.
|
||||||
|
validations:
|
||||||
|
required: true
|
100
.github/workflows/dotnet.yml
vendored
100
.github/workflows/dotnet.yml
vendored
@ -7,21 +7,18 @@ on:
|
|||||||
# Allows you to run this workflow manually from the Actions tab
|
# Allows you to run this workflow manually from the Actions tab
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
|
||||||
jobs:
|
jobs:
|
||||||
# This workflow contains a single job called "build"
|
|
||||||
build:
|
build:
|
||||||
# The type of runner that the job will run on
|
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
if: "!contains(github.event.head_commit.message, '-noci')"
|
if: "!contains(github.event.head_commit.message, '-noci')"
|
||||||
|
|
||||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
|
||||||
steps:
|
steps:
|
||||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
# Checkout latest with submodules
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
|
# Setup tools
|
||||||
- name: Setup msbuild
|
- name: Setup msbuild
|
||||||
uses: microsoft/setup-msbuild@v1
|
uses: microsoft/setup-msbuild@v1
|
||||||
|
|
||||||
@ -32,113 +29,68 @@ jobs:
|
|||||||
nuget-version: '5.x'
|
nuget-version: '5.x'
|
||||||
|
|
||||||
# Build Il2CppAssemblyUnhollower
|
# Build Il2CppAssemblyUnhollower
|
||||||
- name: Build Il2CppAssemblyUnhollower
|
- run: msbuild lib\Il2CppAssemblyUnhollower\UnhollowerBaseLib\UnhollowerBaseLib.csproj -t:Restore -t:Rebuild -p:Platform="AnyCPU" -p:Configuration=Release
|
||||||
shell: cmd
|
|
||||||
run: msbuild lib\Il2CppAssemblyUnhollower\UnhollowerBaseLib\UnhollowerBaseLib.csproj -t:Restore -t:Rebuild -p:Platform="AnyCPU" -p:Configuration=Release
|
|
||||||
|
|
||||||
# Restore mcs nuget
|
|
||||||
- name: Restore mcs nuget
|
|
||||||
run: nuget restore lib\mcs-unity\mcs.sln
|
|
||||||
|
|
||||||
# Build mcs
|
# Build mcs
|
||||||
- name: Build mcs
|
- run: nuget restore lib\mcs-unity\mcs.sln
|
||||||
shell: cmd
|
- run: msbuild lib\mcs-unity\mcs\mcs.csproj -t:Restore -t:Rebuild -p:Platform="AnyCPU" -p:Configuration=Release
|
||||||
run: msbuild lib\mcs-unity\mcs\mcs.csproj -t:Restore -t:Rebuild -p:Platform="AnyCPU" -p:Configuration=Release
|
|
||||||
|
|
||||||
# Restore NuGet packages
|
# Build UnityExplorer releases, and upload artifacts
|
||||||
- name: Restore UnityExplorer nuget
|
|
||||||
run: nuget restore src\UnityExplorer.sln
|
|
||||||
|
|
||||||
# Build UnityExplorer Releases
|
- run: nuget restore src\UnityExplorer.sln
|
||||||
|
|
||||||
- name: Build UnityExplorer BepInEx Il2Cpp
|
# BepInEx Il2Cpp
|
||||||
shell: cmd
|
- run: msbuild src\UnityExplorer.csproj -t:Rebuild -p:Platform="AnyCPU" -p:Configuration=Release_BIE_Cpp
|
||||||
run: msbuild src\UnityExplorer.csproj -t:Rebuild -p:Platform="AnyCPU" -p:Configuration=Release_BIE_Cpp
|
|
||||||
|
|
||||||
- name: Build UnityExplorer BepInEx 5 Mono
|
|
||||||
shell: cmd
|
|
||||||
run: msbuild src\UnityExplorer.csproj -t:Rebuild -p:Platform="AnyCPU" -p:Configuration=Release_BIE5_Mono
|
|
||||||
|
|
||||||
- name: Build UnityExplorer BepInEx 6 Mono
|
|
||||||
shell: cmd
|
|
||||||
run: msbuild src\UnityExplorer.csproj -t:Rebuild -p:Platform="AnyCPU" -p:Configuration=Release_BIE6_Mono
|
|
||||||
|
|
||||||
- name: Build UnityExplorer MelonLoader Il2Cpp
|
|
||||||
shell: cmd
|
|
||||||
run: msbuild src\UnityExplorer.csproj -t:Rebuild -p:Platform="AnyCPU" -p:Configuration=Release_ML_Cpp
|
|
||||||
|
|
||||||
- name: Build UnityExplorer MelonLoader Mono
|
|
||||||
shell: cmd
|
|
||||||
run: msbuild src\UnityExplorer.csproj -t:Rebuild -p:Platform="AnyCPU" -p:Configuration=Release_ML_Mono
|
|
||||||
|
|
||||||
- name: Build UnityExplorer MelonLoader Legacy Il2Cpp
|
|
||||||
shell: cmd
|
|
||||||
run: msbuild src\UnityExplorer.csproj -t:Rebuild -p:Platform="AnyCPU" -p:Configuration=Release_MLLegacy_Cpp
|
|
||||||
|
|
||||||
- name: Build UnityExplorer MelonLoader Legacy Mono
|
|
||||||
shell: cmd
|
|
||||||
run: msbuild src\UnityExplorer.csproj -t:Rebuild -p:Platform="AnyCPU" -p:Configuration=Release_MLLegacy_Mono
|
|
||||||
|
|
||||||
- name: Build UnityExplorer Standalone Il2Cpp
|
|
||||||
shell: cmd
|
|
||||||
run: msbuild src\UnityExplorer.csproj -t:Rebuild -p:Platform="AnyCPU" -p:Configuration=Release_STANDALONE_Cpp
|
|
||||||
|
|
||||||
- name: Build UnityExplorer Standalone Mono
|
|
||||||
shell: cmd
|
|
||||||
run: msbuild src\UnityExplorer.csproj -t:Rebuild -p:Platform="AnyCPU" -p:Configuration=Release_STANDALONE_Mono
|
|
||||||
|
|
||||||
# Upload artifacts
|
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v2
|
||||||
name: Upload BepInEx Il2Cpp zip
|
|
||||||
with:
|
with:
|
||||||
name: UnityExplorer.BepInEx.Il2Cpp
|
name: UnityExplorer.BepInEx.Il2Cpp
|
||||||
path: ./Release/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
|
- uses: actions/upload-artifact@v2
|
||||||
name: Upload BepInEx 5 Mono zip
|
|
||||||
with:
|
with:
|
||||||
name: UnityExplorer.BepInEx5.Mono
|
name: UnityExplorer.BepInEx5.Mono
|
||||||
path: ./Release/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
|
- uses: actions/upload-artifact@v2
|
||||||
name: Upload BepInEx 6 Mono zip
|
|
||||||
with:
|
with:
|
||||||
name: UnityExplorer.BepInEx6.Mono
|
name: UnityExplorer.BepInEx6.Mono
|
||||||
path: ./Release/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
|
- uses: actions/upload-artifact@v2
|
||||||
name: Upload MelonLoader Il2Cpp zip
|
|
||||||
with:
|
with:
|
||||||
name: UnityExplorer.MelonLoader.Il2Cpp
|
name: UnityExplorer.MelonLoader.Il2Cpp
|
||||||
path: ./Release/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
|
- uses: actions/upload-artifact@v2
|
||||||
name: Upload MelonLoader Mono zip
|
|
||||||
with:
|
with:
|
||||||
name: UnityExplorer.MelonLoader.Mono
|
name: UnityExplorer.MelonLoader.Mono
|
||||||
path: ./Release/UnityExplorer.MelonLoader.Mono/*
|
path: ./Release/UnityExplorer.MelonLoader.Mono/*
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v2
|
# Standalone Il2Cpp
|
||||||
name: Upload MelonLoader Legacy Il2Cpp zip
|
- run: msbuild src\UnityExplorer.csproj -t:Rebuild -p:Platform="AnyCPU" -p:Configuration=Release_STANDALONE_Cpp
|
||||||
with:
|
|
||||||
name: UnityExplorer.MelonLoader_Legacy.Il2Cpp
|
|
||||||
path: ./Release/UnityExplorer.MelonLoader_Legacy.Il2Cpp/*
|
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v2
|
||||||
name: Upload MelonLoader Legacy Mono zip
|
|
||||||
with:
|
|
||||||
name: UnityExplorer.MelonLoader_Legacy.Mono
|
|
||||||
path: ./Release/UnityExplorer.MelonLoader_Legacy.Mono/*
|
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v2
|
|
||||||
name: Upload Standalone Il2Cpp zip
|
|
||||||
with:
|
with:
|
||||||
name: UnityExplorer.Standalone.Il2Cpp
|
name: UnityExplorer.Standalone.Il2Cpp
|
||||||
path: ./Release/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
|
- uses: actions/upload-artifact@v2
|
||||||
name: Upload Standalone Mono zip
|
|
||||||
with:
|
with:
|
||||||
name: UnityExplorer.Standalone.Mono
|
name: UnityExplorer.Standalone.Mono
|
||||||
path: ./Release/UnityExplorer.Standalone.Mono/*
|
path: ./Release/UnityExplorer.Standalone.Mono/*
|
||||||
|
102
README.md
102
README.md
@ -3,47 +3,44 @@
|
|||||||
</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 2021+ (IL2CPP and Mono).
|
||||||
|
</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)
|
# Releases [](../../releases)
|
||||||
|
|
||||||
[](../../releases/latest) [](../../releases/latest)
|
[](../../releases/latest) [](https://github.com/sinai-dev/UnityExplorer/actions) [](../../releases/latest)
|
||||||
| Mod Loader | IL2CPP | Mono |
|
|
||||||
| ----------- | ------ | ---- |
|
|
||||||
| [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) |
|
|
||||||
|
|
||||||
* [Click here for Bleeding Edge releases](https://github.com/sinai-dev/UnityExplorer/actions) (click on the latest workflow and scroll down to Artifacts)
|
## BepInEx
|
||||||
|
|
||||||
### Known issues
|
| Release | IL2CPP | Mono |
|
||||||
* 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.
|
| 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) |
|
||||||
* 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.
|
| BIE 5.X | ✖️ n/a | ✅ [link](https://github.com/sinai-dev/UnityExplorer/releases/latest/download/UnityExplorer.BepInEx5.Mono.zip) |
|
||||||
|
|
||||||
## How to install
|
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.
|
||||||
|
|
||||||
### BepInEx
|
<i>Note: BepInEx 6 is obtainable via [BepisBuilds](https://builds.bepis.io/projects/bepinex_be)</i>
|
||||||
|
|
||||||
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.
|
## MelonLoader
|
||||||
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
|
| Release | IL2CPP | Mono |
|
||||||
|
| ------- | ------ | ---- |
|
||||||
|
| ML 0.4+ | ✅ [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) |
|
||||||
|
|
||||||
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).
|
1. Take the `UnityExplorer.ML.[version].dll` file and put it in the `Mods\` folder created by MelonLoader.
|
||||||
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.
|
|
||||||
|
|
||||||
### Standalone
|
## 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).
|
||||||
|
|
||||||
@ -52,7 +49,7 @@ 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
|
# 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">
|
||||||
@ -62,39 +59,46 @@ 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.
|
||||||
|
* BepInEx: `BepInEx\config\com.sinai.unityexplorer.cfg`
|
||||||
|
* MelonLoader: `UserData\MelonPreferences.cfg`
|
||||||
|
* Standalone `{DLL_location}\UnityExplorer\config.ini`
|
||||||
|
|
||||||
Depending on the release you are using, the config file will be found at:
|
# Building
|
||||||
* BepInEx: `BepInEx\config\com.sinai.unityexplorer.cfg`
|
|
||||||
* MelonLoader: `UserData\MelonPreferences.cfg`
|
|
||||||
* Standalone `{DLL_location}\UnityExplorer\config.ini`
|
|
||||||
|
|
||||||
## 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):
|
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):
|
||||||
|
|
||||||
@ -106,10 +110,10 @@ 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.
|
1. Open the `src\UnityExplorer.sln` project.
|
||||||
2. Build `mcs`, and if using IL2CPP then build `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.
|
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.
|
||||||
|
Binary file not shown.
Submodule lib/Il2CppAssemblyUnhollower updated: 0911fdaca6...0099c25069
Binary file not shown.
@ -3,10 +3,11 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityExplorer.UI.CSConsole.Lexers;
|
using UnityExplorer.CSConsole.Lexers;
|
||||||
|
using UnityExplorer.UI;
|
||||||
using UnityExplorer.UI.Widgets.AutoComplete;
|
using UnityExplorer.UI.Widgets.AutoComplete;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CSConsole
|
namespace UnityExplorer.CSConsole
|
||||||
{
|
{
|
||||||
public class CSAutoCompleter : ISuggestionProvider
|
public class CSAutoCompleter : ISuggestionProvider
|
||||||
{
|
{
|
||||||
@ -22,7 +23,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 +41,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 +55,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,19 +1,21 @@
|
|||||||
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.CSConsole;
|
||||||
|
using UnityExplorer.UI;
|
||||||
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.CSConsole
|
||||||
{
|
{
|
||||||
public static class ConsoleController
|
public static class ConsoleController
|
||||||
{
|
{
|
||||||
@ -35,6 +37,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",
|
||||||
@ -50,6 +54,7 @@ namespace UnityExplorer.UI.CSConsole
|
|||||||
|
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
|
// Make sure console is supported on this platform
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ResetConsole(false);
|
ResetConsole(false);
|
||||||
@ -62,19 +67,41 @@ namespace UnityExplorer.UI.CSConsole
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Setup console
|
||||||
Lexer = new LexerBuilder();
|
Lexer = new LexerBuilder();
|
||||||
Completer = new CSAutoCompleter();
|
Completer = new CSAutoCompleter();
|
||||||
|
|
||||||
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;
|
||||||
Panel.OnAutoIndentToggled += OnToggleAutoIndent;
|
Panel.OnAutoIndentToggled += OnToggleAutoIndent;
|
||||||
Panel.OnCtrlRToggled += OnToggleCtrlRShortcut;
|
Panel.OnCtrlRToggled += OnToggleCtrlRShortcut;
|
||||||
Panel.OnSuggestionsToggled += OnToggleSuggestions;
|
Panel.OnSuggestionsToggled += OnToggleSuggestions;
|
||||||
|
Panel.OnPanelResized += OnInputScrolled;
|
||||||
|
|
||||||
|
// Run startup script
|
||||||
|
try
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
ExplorerCore.LogWarning($"Exception executing startup script: {ex}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -150,15 +177,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 +200,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 +257,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 +290,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 +343,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 +363,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 +378,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 +402,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 +440,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 +620,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.
|
@ -5,14 +5,16 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.UI.CSConsole.Lexers;
|
using UnityExplorer.CSConsole.Lexers;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CSConsole
|
namespace UnityExplorer.CSConsole
|
||||||
{
|
{
|
||||||
public struct MatchInfo
|
public struct MatchInfo
|
||||||
{
|
{
|
||||||
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;
|
||||||
}
|
}
|
@ -2,7 +2,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CSConsole.Lexers
|
namespace UnityExplorer.CSConsole.Lexers
|
||||||
{
|
{
|
||||||
public class CommentLexer : Lexer
|
public class CommentLexer : Lexer
|
||||||
{
|
{
|
@ -2,7 +2,7 @@
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CSConsole.Lexers
|
namespace UnityExplorer.CSConsole.Lexers
|
||||||
{
|
{
|
||||||
public class KeywordLexer : Lexer
|
public class KeywordLexer : Lexer
|
||||||
{
|
{
|
||||||
@ -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,8 +1,8 @@
|
|||||||
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.CSConsole.Lexers
|
||||||
{
|
{
|
||||||
public abstract class Lexer
|
public abstract class Lexer
|
||||||
{
|
{
|
@ -1,6 +1,6 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CSConsole.Lexers
|
namespace UnityExplorer.CSConsole.Lexers
|
||||||
{
|
{
|
||||||
public class NumberLexer : Lexer
|
public class NumberLexer : Lexer
|
||||||
{
|
{
|
@ -1,7 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CSConsole.Lexers
|
namespace UnityExplorer.CSConsole.Lexers
|
||||||
{
|
{
|
||||||
public class StringLexer : Lexer
|
public class StringLexer : Lexer
|
||||||
{
|
{
|
@ -3,7 +3,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CSConsole.Lexers
|
namespace UnityExplorer.CSConsole.Lexers
|
||||||
{
|
{
|
||||||
public class SymbolLexer : Lexer
|
public class SymbolLexer : Lexer
|
||||||
{
|
{
|
||||||
@ -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,13 +1,13 @@
|
|||||||
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
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CSConsole
|
namespace UnityExplorer.CSConsole
|
||||||
{
|
{
|
||||||
public class ScriptEvaluator : Evaluator, IDisposable
|
public class ScriptEvaluator : Evaluator, IDisposable
|
||||||
{
|
{
|
@ -1,19 +1,13 @@
|
|||||||
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;
|
||||||
|
|
||||||
/*
|
namespace UnityExplorer.CSConsole
|
||||||
Welcome to the UnityExplorer C# Console!
|
|
||||||
Use the Help dropdown to see detailed examples of how to use this console.
|
|
||||||
To see your output, use the Log panel or a Console Log window.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CSConsole
|
|
||||||
{
|
{
|
||||||
public class ScriptInteraction : InteractiveBase
|
public class ScriptInteraction : InteractiveBase
|
||||||
{
|
{
|
@ -3,9 +3,9 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityExplorer.Core.Config;
|
using UnityExplorer.Core.Config;
|
||||||
using UnityExplorer.UI.CacheObject.Views;
|
using UnityExplorer.CacheObject.Views;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CacheObject
|
namespace UnityExplorer.CacheObject
|
||||||
{
|
{
|
||||||
public class CacheConfigEntry : CacheObjectBase
|
public class CacheConfigEntry : CacheObjectBase
|
||||||
{
|
{
|
@ -3,9 +3,9 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityExplorer.UI.Inspectors;
|
using UnityExplorer.Inspectors;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CacheObject
|
namespace UnityExplorer.CacheObject
|
||||||
{
|
{
|
||||||
public class CacheField : CacheMember
|
public class CacheField : CacheMember
|
||||||
{
|
{
|
@ -2,10 +2,10 @@
|
|||||||
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.CacheObject.IValues;
|
||||||
using UnityExplorer.UI.CacheObject.IValues;
|
using UnityExplorer.CacheObject.Views;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CacheObject
|
namespace UnityExplorer.CacheObject
|
||||||
{
|
{
|
||||||
public class CacheKeyValuePair : CacheObjectBase
|
public class CacheKeyValuePair : CacheObjectBase
|
||||||
{
|
{
|
@ -2,10 +2,10 @@
|
|||||||
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.CacheObject.IValues;
|
||||||
using UnityExplorer.UI.CacheObject.IValues;
|
using UnityExplorer.CacheObject.Views;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CacheObject
|
namespace UnityExplorer.CacheObject
|
||||||
{
|
{
|
||||||
public class CacheListEntry : CacheObjectBase
|
public class CacheListEntry : CacheObjectBase
|
||||||
{
|
{
|
@ -5,11 +5,12 @@ using System.Reflection;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityExplorer.Core.Runtime;
|
using UnityExplorer.Core.Runtime;
|
||||||
using UnityExplorer.UI.CacheObject.Views;
|
using UnityExplorer.CacheObject.Views;
|
||||||
using UnityExplorer.UI.Inspectors;
|
using UnityExplorer.Inspectors;
|
||||||
using UnityExplorer.UI.Models;
|
using UnityExplorer.UI.Models;
|
||||||
|
using UnityExplorer.UI;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CacheObject
|
namespace UnityExplorer.CacheObject
|
||||||
{
|
{
|
||||||
public abstract class CacheMember : CacheObjectBase
|
public abstract class CacheMember : CacheObjectBase
|
||||||
{
|
{
|
@ -3,9 +3,9 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityExplorer.UI.Inspectors;
|
using UnityExplorer.Inspectors;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CacheObject
|
namespace UnityExplorer.CacheObject
|
||||||
{
|
{
|
||||||
public class CacheMethod : CacheMember
|
public class CacheMethod : CacheMember
|
||||||
{
|
{
|
@ -7,11 +7,12 @@ 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.CacheObject.IValues;
|
||||||
using UnityExplorer.UI.CacheObject.IValues;
|
using UnityExplorer.CacheObject.Views;
|
||||||
using UnityExplorer.UI.Models;
|
using UnityExplorer.UI.Models;
|
||||||
|
using UnityExplorer.UI;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CacheObject
|
namespace UnityExplorer.CacheObject
|
||||||
{
|
{
|
||||||
public enum ValueState
|
public enum ValueState
|
||||||
{
|
{
|
@ -3,9 +3,9 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityExplorer.UI.Inspectors;
|
using UnityExplorer.Inspectors;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CacheObject
|
namespace UnityExplorer.CacheObject
|
||||||
{
|
{
|
||||||
public class CacheProperty : CacheMember
|
public class CacheProperty : CacheMember
|
||||||
{
|
{
|
@ -3,10 +3,10 @@ using System.Collections;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityExplorer.UI.CacheObject;
|
using UnityExplorer.CacheObject;
|
||||||
using UnityExplorer.UI.CacheObject.Views;
|
using UnityExplorer.CacheObject.Views;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CacheObject
|
namespace UnityExplorer.CacheObject
|
||||||
{
|
{
|
||||||
public interface ICacheObjectController
|
public interface ICacheObjectController
|
||||||
{
|
{
|
@ -4,9 +4,10 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.UI.CacheObject;
|
using UnityExplorer.CacheObject;
|
||||||
|
using UnityExplorer.UI;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CacheObject.IValues
|
namespace UnityExplorer.CacheObject.IValues
|
||||||
{
|
{
|
||||||
public class InteractiveColor : InteractiveValue
|
public class InteractiveColor : InteractiveValue
|
||||||
{
|
{
|
@ -5,13 +5,14 @@ using System.Linq;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.UI.CacheObject;
|
using UnityExplorer.CacheObject;
|
||||||
using UnityExplorer.UI.CacheObject.Views;
|
using UnityExplorer.CacheObject.Views;
|
||||||
using UnityExplorer.UI.Inspectors;
|
using UnityExplorer.Inspectors;
|
||||||
|
using UnityExplorer.UI;
|
||||||
using UnityExplorer.UI.Panels;
|
using UnityExplorer.UI.Panels;
|
||||||
using UnityExplorer.UI.Widgets;
|
using UnityExplorer.UI.Widgets;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CacheObject.IValues
|
namespace UnityExplorer.CacheObject.IValues
|
||||||
{
|
{
|
||||||
public class InteractiveDictionary : InteractiveValue, ICellPoolDataSource<CacheKeyValuePairCell>, ICacheObjectController
|
public class InteractiveDictionary : InteractiveValue, ICellPoolDataSource<CacheKeyValuePairCell>, ICacheObjectController
|
||||||
{
|
{
|
@ -5,9 +5,10 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.UI.CacheObject;
|
using UnityExplorer.CacheObject;
|
||||||
|
using UnityExplorer.UI;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CacheObject.IValues
|
namespace UnityExplorer.CacheObject.IValues
|
||||||
{
|
{
|
||||||
public class InteractiveEnum : InteractiveValue
|
public class InteractiveEnum : InteractiveValue
|
||||||
{
|
{
|
@ -5,13 +5,14 @@ using System.Linq;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.UI.CacheObject;
|
using UnityExplorer.CacheObject;
|
||||||
using UnityExplorer.UI.CacheObject.Views;
|
using UnityExplorer.CacheObject.Views;
|
||||||
using UnityExplorer.UI.Inspectors;
|
using UnityExplorer.Inspectors;
|
||||||
|
using UnityExplorer.UI;
|
||||||
using UnityExplorer.UI.Panels;
|
using UnityExplorer.UI.Panels;
|
||||||
using UnityExplorer.UI.Widgets;
|
using UnityExplorer.UI.Widgets;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CacheObject.IValues
|
namespace UnityExplorer.CacheObject.IValues
|
||||||
{
|
{
|
||||||
public class InteractiveList : InteractiveValue, ICellPoolDataSource<CacheListEntryCell>, ICacheObjectController
|
public class InteractiveList : InteractiveValue, ICellPoolDataSource<CacheListEntryCell>, ICacheObjectController
|
||||||
{
|
{
|
@ -6,10 +6,11 @@ using System.Text;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.Core.Config;
|
using UnityExplorer.Core.Config;
|
||||||
using UnityExplorer.UI.CacheObject;
|
using UnityExplorer.CacheObject;
|
||||||
using UnityExplorer.UI.Widgets;
|
using UnityExplorer.UI.Widgets;
|
||||||
|
using UnityExplorer.UI;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CacheObject.IValues
|
namespace UnityExplorer.CacheObject.IValues
|
||||||
{
|
{
|
||||||
public class InteractiveString : InteractiveValue
|
public class InteractiveString : InteractiveValue
|
||||||
{
|
{
|
@ -4,10 +4,11 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.UI.CacheObject;
|
using UnityExplorer.CacheObject;
|
||||||
|
using UnityExplorer.UI;
|
||||||
using UnityExplorer.UI.Models;
|
using UnityExplorer.UI.Models;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CacheObject.IValues
|
namespace UnityExplorer.CacheObject.IValues
|
||||||
{
|
{
|
||||||
public abstract class InteractiveValue : IPooledObject
|
public abstract class InteractiveValue : IPooledObject
|
||||||
{
|
{
|
@ -5,9 +5,10 @@ using System.Reflection;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.UI.CacheObject;
|
using UnityExplorer.CacheObject;
|
||||||
|
using UnityExplorer.UI;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CacheObject.IValues
|
namespace UnityExplorer.CacheObject.IValues
|
||||||
{
|
{
|
||||||
public class InteractiveValueStruct : InteractiveValue
|
public class InteractiveValueStruct : InteractiveValue
|
||||||
{
|
{
|
@ -4,8 +4,9 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
using UnityExplorer.UI;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CacheObject.Views
|
namespace UnityExplorer.CacheObject.Views
|
||||||
{
|
{
|
||||||
public class ConfigEntryCell : CacheObjectCell
|
public class ConfigEntryCell : CacheObjectCell
|
||||||
{
|
{
|
@ -4,11 +4,12 @@ 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.CacheObject.IValues;
|
||||||
using UnityExplorer.UI.CacheObject.IValues;
|
using UnityExplorer.Inspectors;
|
||||||
|
using UnityExplorer.UI;
|
||||||
using UnityExplorer.UI.Widgets;
|
using UnityExplorer.UI.Widgets;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CacheObject.Views
|
namespace UnityExplorer.CacheObject.Views
|
||||||
{
|
{
|
||||||
public class CacheKeyValuePairCell : CacheObjectCell
|
public class CacheKeyValuePairCell : CacheObjectCell
|
||||||
{
|
{
|
@ -4,9 +4,9 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.UI.CacheObject.IValues;
|
using UnityExplorer.CacheObject.IValues;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CacheObject.Views
|
namespace UnityExplorer.CacheObject.Views
|
||||||
{
|
{
|
||||||
public class CacheListEntryCell : CacheObjectCell
|
public class CacheListEntryCell : CacheObjectCell
|
||||||
{
|
{
|
@ -4,9 +4,10 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
using UnityExplorer.UI;
|
||||||
using UnityExplorer.UI.Widgets;
|
using UnityExplorer.UI.Widgets;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CacheObject.Views
|
namespace UnityExplorer.CacheObject.Views
|
||||||
{
|
{
|
||||||
public class CacheMemberCell : CacheObjectCell
|
public class CacheMemberCell : CacheObjectCell
|
||||||
{
|
{
|
@ -4,11 +4,12 @@ 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.CacheObject.IValues;
|
||||||
using UnityExplorer.UI.CacheObject.IValues;
|
using UnityExplorer.Inspectors;
|
||||||
|
using UnityExplorer.UI;
|
||||||
using UnityExplorer.UI.Widgets;
|
using UnityExplorer.UI.Widgets;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CacheObject.Views
|
namespace UnityExplorer.CacheObject.Views
|
||||||
{
|
{
|
||||||
public abstract class CacheObjectCell : ICell
|
public abstract class CacheObjectCell : ICell
|
||||||
{
|
{
|
@ -5,10 +5,11 @@ using System.Reflection;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
using UnityExplorer.UI;
|
||||||
using UnityExplorer.UI.Models;
|
using UnityExplorer.UI.Models;
|
||||||
using UnityExplorer.UI.Widgets.AutoComplete;
|
using UnityExplorer.UI.Widgets.AutoComplete;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.CacheObject.Views
|
namespace UnityExplorer.CacheObject.Views
|
||||||
{
|
{
|
||||||
public class EvaluateWidget : IPooledObject
|
public class EvaluateWidget : IPooledObject
|
||||||
{
|
{
|
@ -116,7 +116,7 @@ namespace UnityExplorer.Core.Config
|
|||||||
Reflection_Signature_Blacklist = new ConfigElement<string>("Member Signature Blacklist",
|
Reflection_Signature_Blacklist = new ConfigElement<string>("Member Signature Blacklist",
|
||||||
"Use this to blacklist certain member signatures if they are known to cause a crash or other issues.\r\n" +
|
"Use this to blacklist certain member signatures if they are known to cause a crash or other issues.\r\n" +
|
||||||
"Seperate signatures with a semicolon ';'.\r\n" +
|
"Seperate signatures with a semicolon ';'.\r\n" +
|
||||||
"For example, to blacklist Camera.main, you would add 'Camera.main;'",
|
"For example, to blacklist Camera.main, you would add 'UnityEngine.Camera.main;'",
|
||||||
"");
|
"");
|
||||||
|
|
||||||
// Internal configs (panel save data)
|
// Internal configs (panel save data)
|
||||||
|
@ -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,13 +1,12 @@
|
|||||||
using System;
|
using HarmonyLib;
|
||||||
|
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;
|
|
||||||
|
|
||||||
|
|
||||||
namespace UnityExplorer.Core.Input
|
namespace UnityExplorer.Core.Input
|
||||||
{
|
{
|
||||||
@ -149,18 +148,97 @@ namespace UnityExplorer.Core.Input
|
|||||||
|
|
||||||
// Patches
|
// Patches
|
||||||
|
|
||||||
private static void SetupPatches()
|
public static void SetupPatches()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ExplorerCore.Loader.SetupCursorPatches();
|
PrefixPropertySetter(typeof(Cursor),
|
||||||
|
"lockState",
|
||||||
|
new HarmonyMethod(typeof(CursorUnlocker).GetMethod(nameof(CursorUnlocker.Prefix_set_lockState))));
|
||||||
|
|
||||||
|
PrefixPropertySetter(typeof(Cursor),
|
||||||
|
"visible",
|
||||||
|
new HarmonyMethod(typeof(CursorUnlocker).GetMethod(nameof(CursorUnlocker.Prefix_set_visible))));
|
||||||
|
|
||||||
|
PrefixPropertySetter(typeof(EventSystem),
|
||||||
|
"current",
|
||||||
|
new HarmonyMethod(typeof(CursorUnlocker).GetMethod(nameof(CursorUnlocker.Prefix_EventSystem_set_current))));
|
||||||
|
|
||||||
|
PrefixMethod(typeof(EventSystem),
|
||||||
|
"SetSelectedGameObject",
|
||||||
|
// some games use a modified version of uGUI that includes this extra int argument on this method.
|
||||||
|
new Type[] { typeof(GameObject), typeof(BaseEventData), typeof(int) },
|
||||||
|
new HarmonyMethod(typeof(CursorUnlocker).GetMethod(nameof(CursorUnlocker.Prefix_EventSystem_SetSelectedGameObject))),
|
||||||
|
// most games use these arguments, we'll use them as our "backup".
|
||||||
|
new Type[] { typeof(GameObject), typeof(BaseEventData) });
|
||||||
|
|
||||||
|
//// Not sure if this one is needed.
|
||||||
|
//PrefixMethod(typeof(PointerInputModule),
|
||||||
|
// "ClearSelection",
|
||||||
|
// new Type[0],
|
||||||
|
// new HarmonyMethod(typeof(CursorUnlocker).GetMethod(nameof(CursorUnlocker.Prefix_PointerInputModule_ClearSelection))));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ExplorerCore.Log($"Exception setting up Harmony patches:\r\n{ex.ReflectionExToString()}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void PrefixMethod(Type type, string method, Type[] arguments, HarmonyMethod prefix, Type[] backupArgs = null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var methodInfo = type.GetMethod(method, ReflectionUtility.FLAGS, null, arguments, null);
|
||||||
|
if (methodInfo == null)
|
||||||
|
{
|
||||||
|
if (backupArgs != null)
|
||||||
|
methodInfo = type.GetMethod(method, ReflectionUtility.FLAGS, null, backupArgs, null);
|
||||||
|
|
||||||
|
if (methodInfo == null)
|
||||||
|
throw new MissingMethodException($"Could not find method for patching - '{type.FullName}.{method}'!");
|
||||||
|
}
|
||||||
|
|
||||||
|
var processor = ExplorerCore.Harmony.CreateProcessor(methodInfo);
|
||||||
|
processor.AddPrefix(prefix);
|
||||||
|
processor.Patch();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
ExplorerCore.Log($"Exception setting up Cursor patches: {e.GetType()}, {e.Message}");
|
ExplorerCore.LogWarning($"Unable to patch {type.Name}.{method}: {e.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void PrefixPropertySetter(Type type, string property, HarmonyMethod prefix)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var processor = ExplorerCore.Harmony.CreateProcessor(type.GetProperty(property, ReflectionUtility.FLAGS).GetSetMethod());
|
||||||
|
processor.AddPrefix(prefix);
|
||||||
|
processor.Patch();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
ExplorerCore.Log($"Unable to patch {type.Name}.set_{property}: {e.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prevent setting non-UnityExplorer objects as selected when menu is open
|
||||||
|
|
||||||
|
public static bool Prefix_EventSystem_SetSelectedGameObject(GameObject __0)
|
||||||
|
{
|
||||||
|
if (!UIManager.ShowMenu || !UIManager.CanvasRoot)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return __0 && __0.transform.root.gameObject.GetInstanceID() == UIManager.CanvasRoot.GetInstanceID();
|
||||||
|
}
|
||||||
|
|
||||||
|
//public static bool Prefix_PointerInputModule_ClearSelection()
|
||||||
|
//{
|
||||||
|
// return !(UIManager.ShowMenu && UIManager.CanvasRoot);
|
||||||
|
//}
|
||||||
|
|
||||||
|
// Force EventSystem.current to be UnityExplorer's when menu is open
|
||||||
|
|
||||||
public static void Prefix_EventSystem_set_current(ref EventSystem value)
|
public static void Prefix_EventSystem_set_current(ref EventSystem value)
|
||||||
{
|
{
|
||||||
if (!settingEventSystem && value)
|
if (!settingEventSystem && value)
|
||||||
|
@ -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
|
||||||
{
|
{
|
||||||
@ -12,6 +12,8 @@ namespace UnityExplorer.Core.Input
|
|||||||
{
|
{
|
||||||
public InputSystem()
|
public InputSystem()
|
||||||
{
|
{
|
||||||
|
SetupSupportedDevices();
|
||||||
|
|
||||||
m_kbCurrentProp = TKeyboard.GetProperty("current");
|
m_kbCurrentProp = TKeyboard.GetProperty("current");
|
||||||
m_kbIndexer = TKeyboard.GetProperty("Item", new Type[] { TKey });
|
m_kbIndexer = TKeyboard.GetProperty("Item", new Type[] { TKey });
|
||||||
|
|
||||||
@ -32,7 +34,37 @@ namespace UnityExplorer.Core.Input
|
|||||||
.GetMethod("ReadValue");
|
.GetMethod("ReadValue");
|
||||||
}
|
}
|
||||||
|
|
||||||
#region reflection cache
|
internal static void SetupSupportedDevices()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// typeof(InputSystem)
|
||||||
|
Type TInputSystem = ReflectionUtility.GetTypeByName("UnityEngine.InputSystem.InputSystem");
|
||||||
|
// InputSystem.settings
|
||||||
|
var settings = TInputSystem.GetProperty("settings", BindingFlags.Public | BindingFlags.Static).GetValue(null, null);
|
||||||
|
// typeof(InputSettings)
|
||||||
|
Type TSettings = settings.GetActualType();
|
||||||
|
// InputSettings.supportedDevices
|
||||||
|
PropertyInfo supportedProp = TSettings.GetProperty("supportedDevices", BindingFlags.Public | BindingFlags.Instance);
|
||||||
|
var supportedDevices = supportedProp.GetValue(settings, null);
|
||||||
|
// An empty supportedDevices list means all devices are supported.
|
||||||
|
#if CPP
|
||||||
|
// weird hack for il2cpp, use the implicit operator and cast Il2CppStringArray to ReadOnlyArray<string>
|
||||||
|
var args = new object[] { new UnhollowerBaseLib.Il2CppStringArray(0) };
|
||||||
|
var method = supportedDevices.GetActualType().GetMethod("op_Implicit", BindingFlags.Static | BindingFlags.Public);
|
||||||
|
supportedProp.SetValue(settings, method.Invoke(null, args), null);
|
||||||
|
#else
|
||||||
|
supportedProp.SetValue(settings, Activator.CreateInstance(supportedDevices.GetActualType(), new object[] { new string[0] }), null);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ExplorerCore.LogWarning($"Exception setting up InputSystem.settings.supportedDevices list!");
|
||||||
|
ExplorerCore.Log(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region reflection cache
|
||||||
|
|
||||||
public static Type TKeyboard => m_tKeyboard ?? (m_tKeyboard = ReflectionUtility.GetTypeByName("UnityEngine.InputSystem.Keyboard"));
|
public static Type TKeyboard => m_tKeyboard ?? (m_tKeyboard = ReflectionUtility.GetTypeByName("UnityEngine.InputSystem.Keyboard"));
|
||||||
private static Type m_tKeyboard;
|
private static Type m_tKeyboard;
|
||||||
@ -73,7 +105,7 @@ namespace UnityExplorer.Core.Input
|
|||||||
private static object m_scrollInfo;
|
private static object m_scrollInfo;
|
||||||
private static PropertyInfo m_scrollDeltaProp;
|
private static PropertyInfo m_scrollDeltaProp;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public Vector2 MousePosition
|
public Vector2 MousePosition
|
||||||
{
|
{
|
||||||
@ -138,6 +170,8 @@ namespace UnityExplorer.Core.Input
|
|||||||
|
|
||||||
public bool GetMouseButtonDown(int btn)
|
public bool GetMouseButtonDown(int btn)
|
||||||
{
|
{
|
||||||
|
if (CurrentMouse == null)
|
||||||
|
return false;
|
||||||
switch (btn)
|
switch (btn)
|
||||||
{
|
{
|
||||||
case 0: return (bool)m_btnWasPressedProp.GetValue(LeftMouseButton, null);
|
case 0: return (bool)m_btnWasPressedProp.GetValue(LeftMouseButton, null);
|
||||||
@ -149,6 +183,8 @@ namespace UnityExplorer.Core.Input
|
|||||||
|
|
||||||
public bool GetMouseButton(int btn)
|
public bool GetMouseButton(int btn)
|
||||||
{
|
{
|
||||||
|
if (CurrentMouse == null)
|
||||||
|
return false;
|
||||||
switch (btn)
|
switch (btn)
|
||||||
{
|
{
|
||||||
case 0: return (bool)m_btnIsPressedProp.GetValue(LeftMouseButton, null);
|
case 0: return (bool)m_btnIsPressedProp.GetValue(LeftMouseButton, null);
|
||||||
|
@ -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,13 +26,18 @@ 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
|
||||||
|
|
||||||
// Extern C++ methods
|
// Extern C++ methods
|
||||||
[DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
[DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||||
@ -57,29 +63,21 @@ namespace UnityExplorer
|
|||||||
return il2cppPtr != IntPtr.Zero;
|
return il2cppPtr != IntPtr.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region Deobfuscation cache
|
#region Deobfuscation cache
|
||||||
|
|
||||||
private static readonly Dictionary<string, Type> DeobfuscatedTypes = new Dictionary<string, Type>();
|
private static readonly Dictionary<string, Type> DeobfuscatedTypes = new Dictionary<string, Type>();
|
||||||
private static readonly Dictionary<string, string> reverseDeobCache = new Dictionary<string, string>();
|
private static readonly Dictionary<string, string> reverseDeobCache = new Dictionary<string, string>();
|
||||||
|
|
||||||
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)
|
||||||
@ -113,7 +111,7 @@ namespace UnityExplorer
|
|||||||
return theString;
|
return theString;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
// Get type by name
|
// Get type by name
|
||||||
@ -126,7 +124,7 @@ namespace UnityExplorer
|
|||||||
return base.Internal_GetTypeByName(fullName);
|
return base.Internal_GetTypeByName(fullName);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Get actual type
|
#region Get actual type
|
||||||
|
|
||||||
internal override Type Internal_GetActualType(object obj)
|
internal override Type Internal_GetActualType(object obj)
|
||||||
{
|
{
|
||||||
@ -134,7 +132,6 @@ namespace UnityExplorer
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
var type = obj.GetType();
|
var type = obj.GetType();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (IsString(obj))
|
if (IsString(obj))
|
||||||
@ -185,10 +182,10 @@ namespace UnityExplorer
|
|||||||
return monoType;
|
return monoType;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region Casting
|
#region Casting
|
||||||
|
|
||||||
private static readonly Dictionary<string, IntPtr> cppClassPointers = new Dictionary<string, IntPtr>();
|
private static readonly Dictionary<string, IntPtr> cppClassPointers = new Dictionary<string, IntPtr>();
|
||||||
|
|
||||||
@ -218,7 +215,7 @@ namespace UnityExplorer
|
|||||||
// from other structs to il2cpp object
|
// from other structs to il2cpp object
|
||||||
else if (typeof(Il2CppSystem.Object).IsAssignableFrom(castTo))
|
else if (typeof(Il2CppSystem.Object).IsAssignableFrom(castTo))
|
||||||
{
|
{
|
||||||
return BoxIl2CppObject(obj);
|
return BoxIl2CppObject(obj).TryCast(castTo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return obj;
|
return obj;
|
||||||
@ -280,10 +277,10 @@ namespace UnityExplorer
|
|||||||
// return il2cpp_class_is_assignable_from(thisTypePtr, fromTypePtr);
|
// return il2cpp_class_is_assignable_from(thisTypePtr, fromTypePtr);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region Boxing and unboxing ValueTypes
|
#region Boxing and unboxing ValueTypes
|
||||||
|
|
||||||
// cached il2cpp unbox methods
|
// cached il2cpp unbox methods
|
||||||
internal static readonly Dictionary<string, MethodInfo> unboxMethods = new Dictionary<string, MethodInfo>();
|
internal static readonly Dictionary<string, MethodInfo> unboxMethods = new Dictionary<string, MethodInfo>();
|
||||||
@ -297,7 +294,27 @@ namespace UnityExplorer
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (toType.IsEnum)
|
if (toType.IsEnum)
|
||||||
|
{
|
||||||
|
// Check for nullable enums
|
||||||
|
var type = cppObj.GetType();
|
||||||
|
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Il2CppSystem.Nullable<>))
|
||||||
|
{
|
||||||
|
var nullable = cppObj.TryCast(type);
|
||||||
|
var nullableHasValueProperty = type.GetProperty("HasValue");
|
||||||
|
if ((bool)nullableHasValueProperty.GetValue(nullable, null))
|
||||||
|
{
|
||||||
|
// nullable has a value.
|
||||||
|
var nullableValueProperty = type.GetProperty("Value");
|
||||||
|
return Enum.Parse(toType, nullableValueProperty.GetValue(nullable, null).ToString());
|
||||||
|
}
|
||||||
|
// nullable and no current value.
|
||||||
|
return cppObj;
|
||||||
|
}
|
||||||
|
|
||||||
return Enum.Parse(toType, cppObj.ToString());
|
return Enum.Parse(toType, cppObj.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not enum, unbox with Il2CppObjectBase.Unbox
|
||||||
|
|
||||||
var name = toType.AssemblyQualifiedName;
|
var name = toType.AssemblyQualifiedName;
|
||||||
|
|
||||||
@ -386,10 +403,10 @@ namespace UnityExplorer
|
|||||||
return cppStruct;
|
return cppStruct;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region String boxing/unboxing
|
#region String boxing/unboxing
|
||||||
|
|
||||||
private const string IL2CPP_STRING_FULLNAME = "Il2CppSystem.String";
|
private const string IL2CPP_STRING_FULLNAME = "Il2CppSystem.String";
|
||||||
private const string STRING_FULLNAME = "System.String";
|
private const string STRING_FULLNAME = "System.String";
|
||||||
@ -430,10 +447,10 @@ namespace UnityExplorer
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region Singleton finder
|
#region Singleton finder
|
||||||
|
|
||||||
internal override void Internal_FindSingleton(string[] possibleNames, Type type, BF flags, List<object> instances)
|
internal override void Internal_FindSingleton(string[] possibleNames, Type type, BF flags, List<object> instances)
|
||||||
{
|
{
|
||||||
@ -455,16 +472,16 @@ namespace UnityExplorer
|
|||||||
base.Internal_FindSingleton(possibleNames, type, flags, instances);
|
base.Internal_FindSingleton(possibleNames, type, flags, instances);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region Force-loading game modules
|
#region Force-loading game modules
|
||||||
|
|
||||||
internal static string UnhollowedFolderPath => Path.GetFullPath(
|
internal static string UnhollowedFolderPath => Path.GetFullPath(
|
||||||
#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
|
||||||
@ -515,10 +532,10 @@ namespace UnityExplorer
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region Il2cpp reflection blacklist
|
#region Il2cpp reflection blacklist
|
||||||
|
|
||||||
public override string[] DefaultReflectionBlacklist => defaultIl2CppBlacklist.ToArray();
|
public override string[] DefaultReflectionBlacklist => defaultIl2CppBlacklist.ToArray();
|
||||||
|
|
||||||
@ -667,10 +684,10 @@ namespace UnityExplorer
|
|||||||
"UnityEngine.XR.InputDevice.SendHapticImpulse",
|
"UnityEngine.XR.InputDevice.SendHapticImpulse",
|
||||||
};
|
};
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region IL2CPP IEnumerable and IDictionary
|
#region IL2CPP IEnumerable and IDictionary
|
||||||
|
|
||||||
protected override bool Internal_TryGetEntryType(Type enumerableType, out Type type)
|
protected override bool Internal_TryGetEntryType(Type enumerableType, out Type type)
|
||||||
{
|
{
|
||||||
@ -782,21 +799,24 @@ namespace UnityExplorer
|
|||||||
|
|
||||||
// Some ugly reflection to use the il2cpp interface for the instance type
|
// Some ugly reflection to use the il2cpp interface for the instance type
|
||||||
|
|
||||||
var type = list.GetType();
|
var type = list.GetActualType();
|
||||||
var key = type.AssemblyQualifiedName;
|
var key = type.AssemblyQualifiedName;
|
||||||
|
|
||||||
if (!getEnumeratorMethods.ContainsKey(key))
|
if (!getEnumeratorMethods.ContainsKey(key))
|
||||||
{
|
{
|
||||||
getEnumeratorMethods.Add(key, type.GetMethod("GetEnumerator"));
|
var method = type.GetMethod("GetEnumerator")
|
||||||
|
?? type.GetMethod("System_Collections_IEnumerable_GetEnumerator", FLAGS);
|
||||||
|
getEnumeratorMethods.Add(key, method);
|
||||||
|
|
||||||
// ensure the enumerator type is supported
|
// ensure the enumerator type is supported
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var test = getEnumeratorMethods[key].Invoke(list, null);
|
var test = getEnumeratorMethods[key].Invoke(list, null);
|
||||||
test.GetType().GetMethod("MoveNext").Invoke(test, null);
|
test.GetActualType().GetMethod("MoveNext").Invoke(test, null);
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
ExplorerCore.Log($"IEnumerable failed to enumerate: {ex}");
|
||||||
notSupportedTypes.Add(key);
|
notSupportedTypes.Add(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -805,7 +825,7 @@ namespace UnityExplorer
|
|||||||
throw new NotSupportedException($"The IEnumerable type '{type.FullName}' does not support MoveNext.");
|
throw new NotSupportedException($"The IEnumerable type '{type.FullName}' does not support MoveNext.");
|
||||||
|
|
||||||
cppEnumerator = getEnumeratorMethods[key].Invoke(list, null);
|
cppEnumerator = getEnumeratorMethods[key].Invoke(list, null);
|
||||||
var enumeratorType = cppEnumerator.GetType();
|
var enumeratorType = cppEnumerator.GetActualType();
|
||||||
|
|
||||||
var enumInfoKey = enumeratorType.AssemblyQualifiedName;
|
var enumInfoKey = enumeratorType.AssemblyQualifiedName;
|
||||||
|
|
||||||
@ -859,7 +879,7 @@ namespace UnityExplorer
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var type = dictionary.GetType();
|
var type = dictionary.GetActualType();
|
||||||
|
|
||||||
if (typeof(Il2CppSystem.Collections.Hashtable).IsAssignableFrom(type))
|
if (typeof(Il2CppSystem.Collections.Hashtable).IsAssignableFrom(type))
|
||||||
{
|
{
|
||||||
@ -869,20 +889,23 @@ namespace UnityExplorer
|
|||||||
|
|
||||||
var keys = type.GetProperty("Keys").GetValue(dictionary, null);
|
var keys = type.GetProperty("Keys").GetValue(dictionary, null);
|
||||||
|
|
||||||
var keyCollType = keys.GetType();
|
var keyCollType = keys.GetActualType();
|
||||||
var cacheKey = keys.GetType().AssemblyQualifiedName;
|
var cacheKey = keyCollType.AssemblyQualifiedName;
|
||||||
if (!getEnumeratorMethods.ContainsKey(cacheKey))
|
if (!getEnumeratorMethods.ContainsKey(cacheKey))
|
||||||
{
|
{
|
||||||
getEnumeratorMethods.Add(cacheKey, keyCollType.GetMethod("GetEnumerator"));
|
var method = keyCollType.GetMethod("GetEnumerator")
|
||||||
|
?? keyCollType.GetMethod("System_Collections_IDictionary_GetEnumerator", FLAGS);
|
||||||
|
getEnumeratorMethods.Add(cacheKey, method);
|
||||||
|
|
||||||
// test support
|
// test support
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var test = getEnumeratorMethods[cacheKey].Invoke(keys, null);
|
var test = getEnumeratorMethods[cacheKey].Invoke(keys, null);
|
||||||
test.GetType().GetMethod("MoveNext").Invoke(test, null);
|
test.GetActualType().GetMethod("MoveNext").Invoke(test, null);
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
ExplorerCore.Log($"IDictionary failed to enumerate: {ex}");
|
||||||
notSupportedTypes.Add(cacheKey);
|
notSupportedTypes.Add(cacheKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -893,16 +916,16 @@ namespace UnityExplorer
|
|||||||
var keyEnumerator = getEnumeratorMethods[cacheKey].Invoke(keys, null);
|
var keyEnumerator = getEnumeratorMethods[cacheKey].Invoke(keys, null);
|
||||||
var keyInfo = new EnumeratorInfo
|
var keyInfo = new EnumeratorInfo
|
||||||
{
|
{
|
||||||
current = keyEnumerator.GetType().GetProperty("Current"),
|
current = keyEnumerator.GetActualType().GetProperty("Current"),
|
||||||
moveNext = keyEnumerator.GetType().GetMethod("MoveNext"),
|
moveNext = keyEnumerator.GetActualType().GetMethod("MoveNext"),
|
||||||
};
|
};
|
||||||
|
|
||||||
var values = type.GetProperty("Values").GetValue(dictionary, null);
|
var values = type.GetProperty("Values").GetValue(dictionary, null);
|
||||||
var valueEnumerator = values.GetType().GetMethod("GetEnumerator").Invoke(values, null);
|
var valueEnumerator = values.GetActualType().GetMethod("GetEnumerator").Invoke(values, null);
|
||||||
var valueInfo = new EnumeratorInfo
|
var valueInfo = new EnumeratorInfo
|
||||||
{
|
{
|
||||||
current = valueEnumerator.GetType().GetProperty("Current"),
|
current = valueEnumerator.GetActualType().GetProperty("Current"),
|
||||||
moveNext = valueEnumerator.GetType().GetMethod("MoveNext"),
|
moveNext = valueEnumerator.GetActualType().GetMethod("MoveNext"),
|
||||||
};
|
};
|
||||||
|
|
||||||
dictEnumerator = EnumerateCppDict(keyInfo, keyEnumerator, valueInfo, valueEnumerator);
|
dictEnumerator = EnumerateCppDict(keyInfo, keyEnumerator, valueInfo, valueEnumerator);
|
||||||
|
@ -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)
|
||||||
@ -221,7 +219,7 @@ namespace UnityExplorer
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region Type and Generic Parameter implementation cache
|
#region Type and Generic Parameter implementation cache
|
||||||
@ -356,7 +354,7 @@ namespace UnityExplorer
|
|||||||
return genericParameterInheritance[key];
|
return genericParameterInheritance[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region Internal MemberInfo Cache
|
#region Internal MemberInfo Cache
|
||||||
|
@ -32,16 +32,6 @@ namespace UnityExplorer
|
|||||||
return new AssetBundle(ptr);
|
return new AssetBundle(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// static void UnloadAllAssetBundles(bool unloadAllObjects);
|
|
||||||
|
|
||||||
internal delegate void d_UnloadAllAssetBundles(bool unloadAllObjects);
|
|
||||||
|
|
||||||
public static void UnloadAllAssetBundles(bool unloadAllObjects)
|
|
||||||
{
|
|
||||||
var iCall = ICallManager.GetICall<d_UnloadAllAssetBundles>("UnityEngine.AssetBundle::UnloadAllAssetBundles");
|
|
||||||
iCall.Invoke(unloadAllObjects);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ~~~~~~~~~~~~ Instance ~~~~~~~~~~~~
|
// ~~~~~~~~~~~~ Instance ~~~~~~~~~~~~
|
||||||
|
|
||||||
private readonly IntPtr m_bundlePtr = IntPtr.Zero;
|
private readonly IntPtr m_bundlePtr = IntPtr.Zero;
|
||||||
@ -78,7 +68,8 @@ namespace UnityExplorer
|
|||||||
return new UnityEngine.Object(ptr).TryCast<T>();
|
return new UnityEngine.Object(ptr).TryCast<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// public extern void Unload(bool unloadAllLoadedObjects);
|
// Unload(bool unloadAllLoadedObjects);
|
||||||
|
|
||||||
internal delegate void d_Unload(IntPtr _this, bool unloadAllLoadedObjects);
|
internal delegate void d_Unload(IntPtr _this, bool unloadAllLoadedObjects);
|
||||||
|
|
||||||
public void Unload(bool unloadAssets = true)
|
public void Unload(bool unloadAssets = true)
|
||||||
|
@ -7,7 +7,6 @@ using System.Runtime.InteropServices;
|
|||||||
|
|
||||||
namespace UnityExplorer.Core.Runtime.Il2Cpp
|
namespace UnityExplorer.Core.Runtime.Il2Cpp
|
||||||
{
|
{
|
||||||
[SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "External methods")]
|
|
||||||
public static class ICallManager
|
public static class ICallManager
|
||||||
{
|
{
|
||||||
[DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
[DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||||
|
@ -6,8 +6,8 @@ using System.Linq;
|
|||||||
using UnhollowerBaseLib;
|
using UnhollowerBaseLib;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
// CREDIT HerpDerpenstine
|
// Credit to HerpDerpenstine and knah
|
||||||
// https://github.com/LavaGang/MelonLoader/blob/master/MelonLoader.Support.Il2Cpp/MelonCoroutines.cs
|
// https://github.com/LavaGang/MelonLoader/blob/master/SM_Il2Cpp/Coroutines.cs
|
||||||
|
|
||||||
namespace UnityExplorer.Core.Runtime.Il2Cpp
|
namespace UnityExplorer.Core.Runtime.Il2Cpp
|
||||||
{
|
{
|
||||||
|
@ -73,6 +73,7 @@ namespace UnityExplorer.Core.Runtime.Il2Cpp
|
|||||||
return ScriptableObject.CreateInstance(Il2CppType.From(type));
|
return ScriptableObject.CreateInstance(Il2CppType.From(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pretty disgusting but couldn't figure out a cleaner way yet unfortunately
|
||||||
public override void GraphicRaycast(GraphicRaycaster raycaster, PointerEventData data, List<RaycastResult> list)
|
public override void GraphicRaycast(GraphicRaycaster raycaster, PointerEventData data, List<RaycastResult> list)
|
||||||
{
|
{
|
||||||
var il2cppList = new Il2CppSystem.Collections.Generic.List<RaycastResult>();
|
var il2cppList = new Il2CppSystem.Collections.Generic.List<RaycastResult>();
|
||||||
@ -117,22 +118,17 @@ namespace UnityExplorer.Core.Runtime.Il2Cpp
|
|||||||
if (!scene.isLoaded)
|
if (!scene.isLoaded)
|
||||||
return new GameObject[0];
|
return new GameObject[0];
|
||||||
|
|
||||||
int handle = scene.handle;
|
if (scene.handle == -1)
|
||||||
|
|
||||||
if (handle == -1)
|
|
||||||
return new GameObject[0];
|
return new GameObject[0];
|
||||||
|
|
||||||
int count = GetRootCount(handle);
|
int count = GetRootCount(scene.handle);
|
||||||
|
|
||||||
if (count < 1)
|
if (count < 1)
|
||||||
return new GameObject[0];
|
return new GameObject[0];
|
||||||
|
|
||||||
var list = new Il2CppSystem.Collections.Generic.List<GameObject>(count);
|
var list = new Il2CppSystem.Collections.Generic.List<GameObject>(count);
|
||||||
|
|
||||||
var iCall = ICallManager.GetICall<d_GetRootGameObjects>("UnityEngine.SceneManagement.Scene::GetRootGameObjectsInternal");
|
var iCall = ICallManager.GetICall<d_GetRootGameObjects>("UnityEngine.SceneManagement.Scene::GetRootGameObjectsInternal");
|
||||||
|
iCall.Invoke(scene.handle, list.Pointer);
|
||||||
iCall.Invoke(handle, list.Pointer);
|
|
||||||
|
|
||||||
return list.ToArray();
|
return list.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,19 +38,6 @@ namespace UnityExplorer.Core.Runtime.Il2Cpp
|
|||||||
return new Il2CppStructArray<byte>(ptr);
|
return new Il2CppStructArray<byte>(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// bool ImageConversion.LoadImage(this Texture2D tex, byte[] data, bool markNonReadable);
|
|
||||||
|
|
||||||
internal delegate bool d_LoadImage(IntPtr tex, IntPtr data, bool markNonReadable);
|
|
||||||
|
|
||||||
public override bool LoadImage(Texture2D tex, byte[] data, bool markNonReadable)
|
|
||||||
{
|
|
||||||
var il2cppArray = (Il2CppStructArray<byte>)data;
|
|
||||||
|
|
||||||
var iCall = ICallManager.GetICall<d_LoadImage>("UnityEngine.ImageConversion::LoadImage");
|
|
||||||
|
|
||||||
return iCall.Invoke(tex.Pointer, il2cppArray.Pointer, markNonReadable);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sprite Sprite.Create
|
// Sprite Sprite.Create
|
||||||
|
|
||||||
public override Sprite CreateSprite(Texture2D texture)
|
public override Sprite CreateSprite(Texture2D texture)
|
||||||
|
@ -10,6 +10,7 @@ using UnityEngine.Events;
|
|||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
using UnityExplorer;
|
||||||
|
|
||||||
namespace UnityExplorer.Core.Runtime.Mono
|
namespace UnityExplorer.Core.Runtime.Mono
|
||||||
{
|
{
|
||||||
@ -18,7 +19,6 @@ namespace UnityExplorer.Core.Runtime.Mono
|
|||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
ExplorerCore.Context = RuntimeContext.Mono;
|
ExplorerCore.Context = RuntimeContext.Mono;
|
||||||
//Reflection = new MonoReflection();
|
|
||||||
TextureUtil = new MonoTextureUtil();
|
TextureUtil = new MonoTextureUtil();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,34 +28,23 @@ namespace UnityExplorer.Core.Runtime.Mono
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void Application_logMessageReceived(string condition, string stackTrace, LogType type)
|
private void Application_logMessageReceived(string condition, string stackTrace, LogType type)
|
||||||
{
|
=> ExplorerCore.LogUnity(condition, type);
|
||||||
ExplorerCore.LogUnity(condition, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void StartCoroutine(IEnumerator routine)
|
public override void StartCoroutine(IEnumerator routine)
|
||||||
{
|
=> ExplorerBehaviour.Instance.StartCoroutine(routine);
|
||||||
ExplorerBehaviour.Instance.StartCoroutine(routine);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override T AddComponent<T>(GameObject obj, Type type)
|
public override T AddComponent<T>(GameObject obj, Type type)
|
||||||
{
|
=> (T)obj.AddComponent(type);
|
||||||
return (T)obj.AddComponent(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override ScriptableObject CreateScriptable(Type type)
|
public override ScriptableObject CreateScriptable(Type type)
|
||||||
{
|
=> ScriptableObject.CreateInstance(type);
|
||||||
return ScriptableObject.CreateInstance(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void GraphicRaycast(GraphicRaycaster raycaster, PointerEventData data, List<RaycastResult> list)
|
public override void GraphicRaycast(GraphicRaycaster raycaster, PointerEventData data, List<RaycastResult> list)
|
||||||
{
|
=> raycaster.Raycast(data, list);
|
||||||
raycaster.Raycast(data, list);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string LayerToName(int layer)
|
public override string LayerToName(int layer)
|
||||||
=> LayerMask.LayerToName(layer);
|
=> LayerMask.LayerToName(layer);
|
||||||
@ -63,25 +52,11 @@ namespace UnityExplorer.Core.Runtime.Mono
|
|||||||
public override UnityEngine.Object[] FindObjectsOfTypeAll(Type type)
|
public override UnityEngine.Object[] FindObjectsOfTypeAll(Type type)
|
||||||
=> Resources.FindObjectsOfTypeAll(type);
|
=> Resources.FindObjectsOfTypeAll(type);
|
||||||
|
|
||||||
//private static readonly FieldInfo fi_Scene_handle = typeof(Scene).GetField("m_Handle", ReflectionUtility.AllFlags);
|
|
||||||
|
|
||||||
//public override int GetSceneHandle(Scene scene)
|
|
||||||
//{
|
|
||||||
// return (int)fi_Scene_handle.GetValue(scene);
|
|
||||||
//}
|
|
||||||
|
|
||||||
public override GameObject[] GetRootGameObjects(Scene scene)
|
public override GameObject[] GetRootGameObjects(Scene scene)
|
||||||
{
|
=> scene.isLoaded ? scene.GetRootGameObjects() : new GameObject[0];
|
||||||
if (!scene.isLoaded)
|
|
||||||
return new GameObject[0];
|
|
||||||
|
|
||||||
return scene.GetRootGameObjects();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int GetRootCount(Scene scene)
|
public override int GetRootCount(Scene scene)
|
||||||
{
|
=> scene.rootCount;
|
||||||
return scene.rootCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void SetColorBlock(Selectable selectable, Color? normal = null, Color? highlighted = null, Color? pressed = null,
|
public override void SetColorBlock(Selectable selectable, Color? normal = null, Color? highlighted = null, Color? pressed = null,
|
||||||
Color? disabled = null)
|
Color? disabled = null)
|
||||||
@ -104,58 +79,41 @@ namespace UnityExplorer.Core.Runtime.Mono
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void SetColorBlock(Selectable selectable, ColorBlock colors)
|
public override void SetColorBlock(Selectable selectable, ColorBlock colors)
|
||||||
{
|
=> selectable.colors = colors;
|
||||||
selectable.colors = colors;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MonoExtensions
|
public static class MonoExtensions
|
||||||
{
|
{
|
||||||
|
// Helpers to use the same style of AddListener that IL2CPP uses.
|
||||||
|
|
||||||
public static void AddListener(this UnityEvent _event, Action listener)
|
public static void AddListener(this UnityEvent _event, Action listener)
|
||||||
{
|
=> _event.AddListener(new UnityAction(listener));
|
||||||
_event.AddListener(new UnityAction(listener));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void AddListener<T>(this UnityEvent<T> _event, Action<T> listener)
|
public static void AddListener<T>(this UnityEvent<T> _event, Action<T> listener)
|
||||||
{
|
=> _event.AddListener(new UnityAction<T>(listener));
|
||||||
_event.AddListener(new UnityAction<T>(listener));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void RemoveListener(this UnityEvent _event, Action listener)
|
public static void RemoveListener(this UnityEvent _event, Action listener)
|
||||||
{
|
=> _event.RemoveListener(new UnityAction(listener));
|
||||||
_event.RemoveListener(new UnityAction(listener));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void RemoveListener<T>(this UnityEvent<T> _event, Action<T> listener)
|
public static void RemoveListener<T>(this UnityEvent<T> _event, Action<T> listener)
|
||||||
{
|
=> _event.RemoveListener(new UnityAction<T>(listener));
|
||||||
_event.RemoveListener(new UnityAction<T>(listener));
|
|
||||||
}
|
// Doesn't exist in NET 3.5
|
||||||
|
|
||||||
public static void Clear(this StringBuilder sb)
|
public static void Clear(this StringBuilder sb)
|
||||||
{
|
=> sb.Remove(0, sb.Length);
|
||||||
sb.Remove(0, sb.Length);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static PropertyInfo pi_childControlHeight;
|
// These properties don't exist in some earlier games, so null check before trying to set them.
|
||||||
|
|
||||||
public static void SetChildControlHeight(this HorizontalOrVerticalLayoutGroup group, bool value)
|
public static void SetChildControlHeight(this HorizontalOrVerticalLayoutGroup group, bool value)
|
||||||
{
|
=> ReflectionUtility.GetPropertyInfo(typeof(HorizontalOrVerticalLayoutGroup), "childControlHeight")
|
||||||
if (pi_childControlHeight == null)
|
?.SetValue(group, value, null);
|
||||||
pi_childControlHeight = group.GetType().GetProperty("childControlHeight");
|
|
||||||
|
|
||||||
pi_childControlHeight?.SetValue(group, value, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static PropertyInfo pi_childControlWidth;
|
|
||||||
|
|
||||||
public static void SetChildControlWidth(this HorizontalOrVerticalLayoutGroup group, bool value)
|
public static void SetChildControlWidth(this HorizontalOrVerticalLayoutGroup group, bool value)
|
||||||
{
|
=> ReflectionUtility.GetPropertyInfo(typeof(HorizontalOrVerticalLayoutGroup), "childControlWidth")
|
||||||
if (pi_childControlWidth == null)
|
?.SetValue(group, value, null);
|
||||||
pi_childControlWidth = group.GetType().GetProperty("childControlWidth");
|
|
||||||
|
|
||||||
pi_childControlWidth?.SetValue(group, value, null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -12,41 +12,28 @@ namespace UnityExplorer.Core.Runtime.Mono
|
|||||||
public class MonoTextureUtil : TextureUtilProvider
|
public class MonoTextureUtil : TextureUtilProvider
|
||||||
{
|
{
|
||||||
public override void Blit(Texture2D tex, RenderTexture rt)
|
public override void Blit(Texture2D tex, RenderTexture rt)
|
||||||
{
|
=> Graphics.Blit(tex, rt);
|
||||||
Graphics.Blit(tex, rt);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Sprite CreateSprite(Texture2D texture)
|
public override Sprite CreateSprite(Texture2D texture)
|
||||||
{
|
=> Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero);
|
||||||
return Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool LoadImage(Texture2D tex, byte[] data, bool markNonReadable)
|
//public override bool LoadImage(Texture2D tex, byte[] data, bool markNonReadable)
|
||||||
{
|
// => tex.LoadImage(data, markNonReadable);
|
||||||
return tex.LoadImage(data, markNonReadable);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Texture2D NewTexture2D(int width, int height)
|
public override Texture2D NewTexture2D(int width, int height)
|
||||||
{
|
=> new Texture2D(width, height);
|
||||||
return new Texture2D(width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override byte[] EncodeToPNG(Texture2D tex)
|
public override byte[] EncodeToPNG(Texture2D tex)
|
||||||
{
|
=> EncodeToPNGSafe(tex);
|
||||||
return EncodeToPNGSafe(tex);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static MethodInfo EncodeToPNGMethod => m_encodeToPNGMethod ?? GetEncodeToPNGMethod();
|
private static MethodInfo EncodeToPNGMethod => m_encodeToPNGMethod ?? GetEncodeToPNGMethod();
|
||||||
private static MethodInfo m_encodeToPNGMethod;
|
private static MethodInfo m_encodeToPNGMethod;
|
||||||
|
|
||||||
public static byte[] EncodeToPNGSafe(Texture2D tex)
|
public static byte[] EncodeToPNGSafe(Texture2D tex)
|
||||||
{
|
{
|
||||||
var method = EncodeToPNGMethod;
|
return EncodeToPNGMethod.IsStatic
|
||||||
|
? (byte[])EncodeToPNGMethod.Invoke(null, new object[] { tex })
|
||||||
if (method.IsStatic)
|
: (byte[])EncodeToPNGMethod.Invoke(tex, ArgumentUtility.EmptyArgs);
|
||||||
return (byte[])method.Invoke(null, new object[] { tex });
|
|
||||||
else
|
|
||||||
return (byte[])method.Invoke(tex, ArgumentUtility.EmptyArgs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MethodInfo GetEncodeToPNGMethod()
|
private static MethodInfo GetEncodeToPNGMethod()
|
||||||
|
@ -40,8 +40,6 @@ namespace UnityExplorer
|
|||||||
|
|
||||||
public abstract void Update();
|
public abstract void Update();
|
||||||
|
|
||||||
//public virtual bool IsReferenceEqual(object a, object b) => ReferenceEquals(a, b);
|
|
||||||
|
|
||||||
// Unity API handlers
|
// Unity API handlers
|
||||||
|
|
||||||
public abstract T AddComponent<T>(GameObject obj, Type type) where T : Component;
|
public abstract T AddComponent<T>(GameObject obj, Type type) where T : Component;
|
||||||
@ -54,8 +52,6 @@ namespace UnityExplorer
|
|||||||
|
|
||||||
public abstract void GraphicRaycast(GraphicRaycaster raycaster, PointerEventData data, List<RaycastResult> list);
|
public abstract void GraphicRaycast(GraphicRaycaster raycaster, PointerEventData data, List<RaycastResult> list);
|
||||||
|
|
||||||
//public abstract int GetSceneHandle(Scene scene);
|
|
||||||
|
|
||||||
public abstract GameObject[] GetRootGameObjects(Scene scene);
|
public abstract GameObject[] GetRootGameObjects(Scene scene);
|
||||||
|
|
||||||
public abstract int GetRootCount(Scene scene);
|
public abstract int GetRootCount(Scene scene);
|
||||||
|
@ -22,7 +22,7 @@ namespace UnityExplorer.Core.Runtime
|
|||||||
|
|
||||||
public abstract void Blit(Texture2D tex, RenderTexture rt);
|
public abstract void Blit(Texture2D tex, RenderTexture rt);
|
||||||
|
|
||||||
public abstract bool LoadImage(Texture2D tex, byte[] data, bool markNonReadable);
|
//public abstract bool LoadImage(Texture2D tex, byte[] data, bool markNonReadable);
|
||||||
|
|
||||||
public abstract Sprite CreateSprite(Texture2D texture);
|
public abstract Sprite CreateSprite(Texture2D texture);
|
||||||
|
|
||||||
@ -43,27 +43,22 @@ namespace UnityExplorer.Core.Runtime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool LoadImage(Texture2D tex, string filePath, bool markNonReadable)
|
//public static bool LoadImage(Texture2D tex, string filePath, bool markNonReadable)
|
||||||
{
|
//{
|
||||||
if (!File.Exists(filePath))
|
// if (!File.Exists(filePath))
|
||||||
return false;
|
// return false;
|
||||||
|
//
|
||||||
return Instance.LoadImage(tex, File.ReadAllBytes(filePath), markNonReadable);
|
// return Instance.LoadImage(tex, File.ReadAllBytes(filePath), markNonReadable);
|
||||||
}
|
//}
|
||||||
|
|
||||||
public static Texture2D Copy(Texture2D orig, Rect rect)
|
public static Texture2D Copy(Texture2D orig, Rect rect)
|
||||||
{
|
{
|
||||||
Color[] pixels;
|
|
||||||
|
|
||||||
if (!IsReadable(orig))
|
if (!IsReadable(orig))
|
||||||
orig = ForceReadTexture(orig);
|
orig = ForceReadTexture(orig);
|
||||||
|
|
||||||
pixels = orig.GetPixels((int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
|
Color[] pixels = orig.GetPixels((int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
|
||||||
|
|
||||||
Texture2D newTex = Instance.NewTexture2D((int)rect.width, (int)rect.height);
|
Texture2D newTex = Instance.NewTexture2D((int)rect.width, (int)rect.height);
|
||||||
|
|
||||||
newTex.SetPixels(pixels);
|
newTex.SetPixels(pixels);
|
||||||
|
|
||||||
return newTex;
|
return newTex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +87,7 @@ namespace UnityExplorer.Core.Runtime
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
ExplorerCore.Log("Exception on ForceReadTexture: " + e.ToString());
|
ExplorerCore.Log($"Exception on ForceReadTexture: {e.ToString()}");
|
||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -103,13 +98,11 @@ namespace UnityExplorer.Core.Runtime
|
|||||||
Directory.CreateDirectory(dir);
|
Directory.CreateDirectory(dir);
|
||||||
|
|
||||||
byte[] data;
|
byte[] data;
|
||||||
string savepath = dir + @"\" + name + ".png";
|
string savepath = $@"{dir}\{name}.png";
|
||||||
|
|
||||||
// Make sure we can EncodeToPNG it.
|
// Make sure we can EncodeToPNG it.
|
||||||
if (tex.format != TextureFormat.ARGB32 || !IsReadable(tex))
|
if (tex.format != TextureFormat.ARGB32 || !IsReadable(tex))
|
||||||
{
|
|
||||||
tex = ForceReadTexture(tex);
|
tex = ForceReadTexture(tex);
|
||||||
}
|
|
||||||
|
|
||||||
if (isDTXnmNormal)
|
if (isDTXnmNormal)
|
||||||
{
|
{
|
||||||
@ -120,14 +113,10 @@ namespace UnityExplorer.Core.Runtime
|
|||||||
data = Instance.EncodeToPNG(tex);
|
data = Instance.EncodeToPNG(tex);
|
||||||
|
|
||||||
if (data == null || !data.Any())
|
if (data == null || !data.Any())
|
||||||
{
|
|
||||||
ExplorerCore.LogWarning("Couldn't get any data for the texture!");
|
ExplorerCore.LogWarning("Couldn't get any data for the texture!");
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
File.WriteAllBytes(savepath, data);
|
File.WriteAllBytes(savepath, data);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Converts DTXnm-format Normal Map to RGBA-format Normal Map.
|
// Converts DTXnm-format Normal Map to RGBA-format Normal Map.
|
||||||
public static Texture2D DTXnmToRGBA(Texture2D tex)
|
public static Texture2D DTXnmToRGBA(Texture2D tex)
|
||||||
|
@ -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.CacheObject.IValues;
|
||||||
#if CPP
|
#if CPP
|
||||||
using UnhollowerRuntimeLib;
|
using UnhollowerRuntimeLib;
|
||||||
using UnhollowerBaseLib;
|
using UnhollowerBaseLib;
|
||||||
@ -14,112 +14,31 @@ using UnhollowerBaseLib;
|
|||||||
|
|
||||||
namespace UnityExplorer.Tests
|
namespace UnityExplorer.Tests
|
||||||
{
|
{
|
||||||
public class TestIndexer : IList<int>
|
|
||||||
{
|
|
||||||
private readonly List<int> list = new List<int>() { 1,2,3,4,5 };
|
|
||||||
|
|
||||||
public int Count => list.Count;
|
|
||||||
public bool IsReadOnly => false;
|
|
||||||
|
|
||||||
int IList<int>.this[int index]
|
|
||||||
{
|
|
||||||
get => list[index];
|
|
||||||
set => list[index] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int IndexOf(int item) => list.IndexOf(item);
|
|
||||||
public bool Contains(int item) => list.Contains(item);
|
|
||||||
|
|
||||||
public void Add(int item) => list.Add(item);
|
|
||||||
public void Insert(int index, int item) => list.Insert(index, item);
|
|
||||||
|
|
||||||
public bool Remove(int item) => list.Remove(item);
|
|
||||||
public void RemoveAt(int index) => list.RemoveAt(index);
|
|
||||||
|
|
||||||
public void Clear() => list.Clear();
|
|
||||||
|
|
||||||
public void CopyTo(int[] array, int arrayIndex) => list.CopyTo(array, arrayIndex);
|
|
||||||
|
|
||||||
public IEnumerator<int> GetEnumerator() => list.GetEnumerator();
|
|
||||||
IEnumerator IEnumerable.GetEnumerator() => list.GetEnumerator();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class TestClass
|
public static class TestClass
|
||||||
{
|
{
|
||||||
public static readonly TestIndexer AAAAATest = new TestIndexer();
|
static TestClass()
|
||||||
|
|
||||||
public static void ATestMethod(string s, float f, Vector3 vector, DateTime date, Quaternion quater, bool b, CameraClearFlags enumvalue)
|
|
||||||
{
|
{
|
||||||
ExplorerCore.Log($"{s}, {f}, {vector.ToString()}, {date}, {quater.eulerAngles.ToString()}, {b}, {enumvalue}");
|
Init_Mono();
|
||||||
|
#if CPP
|
||||||
|
Init_IL2CPP();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<int> AWritableList = new List<int> { 1, 2, 3, 4, 5 };
|
// Test enumerables
|
||||||
public static Dictionary<string, int> AWritableDict = new Dictionary<string, int> { { "one", 1 }, { "two", 2 } };
|
public static List<object> ListOfInts;
|
||||||
|
public static List<List<List<string>>> NestedList;
|
||||||
public static IEnumerable ANestedList = new List<List<List<string>>>
|
public static IDictionary MixedDictionary;
|
||||||
{
|
public static Hashtable Hashtable;
|
||||||
new List<List<string>>
|
|
||||||
{
|
|
||||||
new List<string>
|
|
||||||
{
|
|
||||||
"one",
|
|
||||||
"two",
|
|
||||||
"one",
|
|
||||||
"two",
|
|
||||||
"one",
|
|
||||||
"two",
|
|
||||||
"one",
|
|
||||||
"two",
|
|
||||||
"one",
|
|
||||||
"two",
|
|
||||||
"one",
|
|
||||||
"two",
|
|
||||||
"one",
|
|
||||||
"two",
|
|
||||||
"one",
|
|
||||||
"two",
|
|
||||||
},
|
|
||||||
new List<string>
|
|
||||||
{
|
|
||||||
"three",
|
|
||||||
"four",
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new List<List<string>>
|
|
||||||
{
|
|
||||||
new List<string>
|
|
||||||
{
|
|
||||||
"five"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public static IDictionary ARandomDictionary = new Dictionary<object, object>
|
|
||||||
{
|
|
||||||
{ 1, 2 },
|
|
||||||
{ "one", "two" },
|
|
||||||
{ true, false },
|
|
||||||
{ new Vector3(0,1,2), new Vector3(1,2,3) },
|
|
||||||
{ CameraClearFlags.Depth, CameraClearFlags.Color },
|
|
||||||
{ "################################################\r\n##########", null },
|
|
||||||
{ "subdict", new Dictionary<object,object> { { "key", "value" } } }
|
|
||||||
};
|
|
||||||
|
|
||||||
public static Hashtable TestHashtable = new Hashtable
|
|
||||||
{
|
|
||||||
{ "one", "value" },
|
|
||||||
{ "two", "value" },
|
|
||||||
{ "three", "value" },
|
|
||||||
};
|
|
||||||
|
|
||||||
public const int ConstantInt = 5;
|
|
||||||
|
|
||||||
public static Color AColor = Color.magenta;
|
|
||||||
public static Color32 AColor32 = Color.red;
|
|
||||||
|
|
||||||
public static byte[] ByteArray = new byte[16];
|
public static byte[] ByteArray = new byte[16];
|
||||||
public static string LongString = new string('#', 10000);
|
public static List<short> ABigList = new List<short>(10000);
|
||||||
public static List<string> BigList = new List<string>(10000);
|
|
||||||
|
// Test const behaviour (should be a readonly field)
|
||||||
|
public const int ConstantInt5 = 5;
|
||||||
|
|
||||||
|
// Testing other InteractiveValues
|
||||||
|
public static Color Color = Color.magenta;
|
||||||
|
public static Color32 Color32 = Color.red;
|
||||||
|
public static string ALongString = new string('#', 10000);
|
||||||
|
|
||||||
public static List<object> RandomList
|
public static List<object> RandomList
|
||||||
{
|
{
|
||||||
@ -133,25 +52,7 @@ namespace UnityExplorer.Tests
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void TestGeneric<T>()
|
// Test methods
|
||||||
{
|
|
||||||
ExplorerCore.Log("Test1 " + typeof(T).FullName);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void TestGenericClass<T>() where T : class
|
|
||||||
{
|
|
||||||
ExplorerCore.Log("Test2 " + typeof(T).FullName);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void TestComponent<T>() where T : Component
|
|
||||||
{
|
|
||||||
ExplorerCore.Log("Test3 " + typeof(T).FullName);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void TestStruct<T>() where T : struct
|
|
||||||
{
|
|
||||||
ExplorerCore.Log("Test3 " + typeof(T).FullName);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static object GetRandomObject()
|
private static object GetRandomObject()
|
||||||
{
|
{
|
||||||
@ -165,109 +66,133 @@ namespace UnityExplorer.Tests
|
|||||||
case 2: return true;
|
case 2: return true;
|
||||||
case 3: return "hello";
|
case 3: return "hello";
|
||||||
case 4: return 50.5f;
|
case 4: return 50.5f;
|
||||||
case 5: return UnityEngine.CameraClearFlags.Color;
|
case 5: return CameraClearFlags.Color;
|
||||||
case 6: return new List<string> { "sub list", "lol" };
|
case 6: return new List<string> { "one", "two" };
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void TestComponent<T>() where T : Component
|
||||||
|
{
|
||||||
|
ExplorerCore.Log($"Test3 {typeof(T).FullName}");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void TestArgumentParse(string s, int i, Color color, CameraClearFlags flags, Vector3 vector, Quaternion quaternion)
|
||||||
|
{
|
||||||
|
ExplorerCore.Log($"{s}, {i}, {color.ToString()}, {flags}, {vector.ToString()}, {quaternion.ToString()}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Init_Mono()
|
||||||
|
{
|
||||||
|
ExplorerCore.Log($"1: Basic list");
|
||||||
|
ListOfInts = new List<object> { 1, 2, 3, 4, 5 };
|
||||||
|
|
||||||
|
ExplorerCore.Log($"2: Nested list");
|
||||||
|
NestedList = new List<List<List<string>>>
|
||||||
|
{
|
||||||
|
new List<List<string>> {
|
||||||
|
new List<string> { "1", "2", "3" },
|
||||||
|
new List<string> { "4", "5", "6" },
|
||||||
|
},
|
||||||
|
new List<List<string>>
|
||||||
|
{
|
||||||
|
new List<string> { "7", "8", "9" }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ExplorerCore.Log($"3: Dictionary");
|
||||||
|
MixedDictionary = new Dictionary<object, object>
|
||||||
|
{
|
||||||
|
{ 1, 2 },
|
||||||
|
{ "one", "two" },
|
||||||
|
{ true, false },
|
||||||
|
{ new Vector3(0,1,2), new Vector3(1,2,3) },
|
||||||
|
{ CameraClearFlags.Depth, CameraClearFlags.Color },
|
||||||
|
{ "################################################\r\n##########", null },
|
||||||
|
{ "subdict", new Dictionary<object,object> { { "key", "value" } } }
|
||||||
|
};
|
||||||
|
|
||||||
|
ExplorerCore.Log($"4: Hashtable");
|
||||||
|
Hashtable = new Hashtable { { "One", 1 }, { "Two", 2 } };
|
||||||
|
|
||||||
|
ExplorerCore.Log($"5: Big list");
|
||||||
|
for (int i = 0; i < ABigList.Capacity; i++)
|
||||||
|
ABigList[i] = (short)UnityEngine.Random.Range(0, short.MaxValue);
|
||||||
|
|
||||||
|
ExplorerCore.Log("Finished TestClass Init_Mono");
|
||||||
|
}
|
||||||
|
|
||||||
#if CPP
|
#if CPP
|
||||||
|
|
||||||
public static Il2CppSystem.Collections.IList IL2CPP_IList;
|
|
||||||
public static Il2CppSystem.Collections.Generic.List<string> IL2CPP_ListString;
|
public static Il2CppSystem.Collections.Generic.List<string> IL2CPP_ListString;
|
||||||
public static Il2CppSystem.Collections.Generic.HashSet<string> IL2CPP_HashSet;
|
|
||||||
|
|
||||||
public static Il2CppSystem.Collections.Generic.Dictionary<string, string> IL2CPP_Dict;
|
|
||||||
public static Il2CppSystem.Collections.Hashtable IL2CPP_HashTable;
|
|
||||||
public static Il2CppSystem.Collections.IDictionary IL2CPP_IDict;
|
|
||||||
|
|
||||||
public static string IL2CPP_systemString = "Test";
|
|
||||||
public static Il2CppSystem.Object IL2CPP_objectString = "string boxed as cpp object";
|
|
||||||
public static Il2CppSystem.String IL2CPP_il2cppString = "string boxed as cpp string";
|
|
||||||
public static string nullString = null;
|
|
||||||
|
|
||||||
public static List<Il2CppSystem.Object> IL2CPP_listOfBoxedObjects;
|
public static List<Il2CppSystem.Object> IL2CPP_listOfBoxedObjects;
|
||||||
public static Il2CppStructArray<int> IL2CPP_structArray;
|
public static Il2CppStructArray<int> IL2CPP_structArray;
|
||||||
public static Il2CppStringArray IL2CPP_stringArray;
|
|
||||||
public static Il2CppReferenceArray<Il2CppSystem.Object> IL2CPP_ReferenceArray;
|
public static Il2CppReferenceArray<Il2CppSystem.Object> IL2CPP_ReferenceArray;
|
||||||
|
public static Il2CppSystem.Collections.IDictionary IL2CPP_IDict;
|
||||||
|
public static Il2CppSystem.Collections.IList IL2CPP_IList;
|
||||||
|
public static Dictionary<Il2CppSystem.String, Il2CppSystem.Object> CppBoxedDict;
|
||||||
|
|
||||||
|
public static Il2CppSystem.Collections.Generic.HashSet<string> IL2CPP_HashSet;
|
||||||
|
public static Il2CppSystem.Collections.Generic.Dictionary<string, string> IL2CPP_Dict;
|
||||||
|
public static Il2CppSystem.Collections.Hashtable IL2CPP_HashTable;
|
||||||
public static Il2CppSystem.Object cppBoxedInt;
|
public static Il2CppSystem.Object cppBoxedInt;
|
||||||
public static Il2CppSystem.Int32 cppInt;
|
public static Il2CppSystem.Int32 cppInt;
|
||||||
public static Il2CppSystem.Decimal cppDecimal;
|
public static Il2CppSystem.Decimal cppDecimal;
|
||||||
public static Il2CppSystem.Object cppDecimalBoxed;
|
public static Il2CppSystem.Object cppDecimalBoxed;
|
||||||
public static Il2CppSystem.Object cppVector3Boxed;
|
public static Il2CppSystem.Object cppVector3Boxed;
|
||||||
|
public static string IL2CPP_systemString = "Test";
|
||||||
|
public static Il2CppSystem.Object IL2CPP_objectString = "string boxed as cpp object";
|
||||||
|
public static Il2CppSystem.String IL2CPP_il2cppString = "string boxed as cpp string";
|
||||||
|
public static string nullString = null;
|
||||||
|
|
||||||
public static Il2CppSystem.Object RandomBoxedColor
|
private static void Init_IL2CPP()
|
||||||
{
|
{
|
||||||
get
|
ExplorerCore.Log($"IL2CPP 1: Il2Cpp Dictionary<string, string>");
|
||||||
{
|
|
||||||
int ran = UnityEngine.Random.Range(0, 3);
|
|
||||||
switch (ran)
|
|
||||||
{
|
|
||||||
case 1: return new Color32().BoxIl2CppObject();
|
|
||||||
case 2: return Color.magenta.BoxIl2CppObject();
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Il2CppSystem.Collections.Hashtable cppHashset;
|
|
||||||
|
|
||||||
public static Dictionary<Il2CppSystem.String, Il2CppSystem.Object> CppBoxedDict;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static TestClass()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < BigList.Capacity; i++)
|
|
||||||
BigList.Add(i.ToString());
|
|
||||||
|
|
||||||
#if CPP
|
|
||||||
IL2CPP_Dict = new Il2CppSystem.Collections.Generic.Dictionary<string, string>();
|
IL2CPP_Dict = new Il2CppSystem.Collections.Generic.Dictionary<string, string>();
|
||||||
IL2CPP_Dict.Add("key1", "value1");
|
IL2CPP_Dict.Add("key1", "value1");
|
||||||
IL2CPP_Dict.Add("key2", "value2");
|
IL2CPP_Dict.Add("key2", "value2");
|
||||||
IL2CPP_Dict.Add("key3", "value3");
|
IL2CPP_Dict.Add("key3", "value3");
|
||||||
|
|
||||||
|
ExplorerCore.Log($"IL2CPP 2: Il2Cpp Hashtable");
|
||||||
IL2CPP_HashTable = new Il2CppSystem.Collections.Hashtable();
|
IL2CPP_HashTable = new Il2CppSystem.Collections.Hashtable();
|
||||||
IL2CPP_HashTable.Add("key1", "value1");
|
IL2CPP_HashTable.Add("key1", "value1");
|
||||||
IL2CPP_HashTable.Add("key2", "value2");
|
IL2CPP_HashTable.Add("key2", "value2");
|
||||||
IL2CPP_HashTable.Add("key3", "value3");
|
IL2CPP_HashTable.Add("key3", "value3");
|
||||||
|
|
||||||
|
ExplorerCore.Log($"IL2CPP 3: Il2Cpp IDictionary");
|
||||||
var dict2 = new Il2CppSystem.Collections.Generic.Dictionary<string, string>();
|
var dict2 = new Il2CppSystem.Collections.Generic.Dictionary<string, string>();
|
||||||
dict2.Add("key1", "value1");
|
dict2.Add("key1", "value1");
|
||||||
IL2CPP_IDict = dict2.TryCast<Il2CppSystem.Collections.IDictionary>();
|
IL2CPP_IDict = dict2.TryCast<Il2CppSystem.Collections.IDictionary>();
|
||||||
|
|
||||||
|
ExplorerCore.Log($"IL2CPP 4: Il2Cpp List of Il2Cpp Object");
|
||||||
var list = new Il2CppSystem.Collections.Generic.List<Il2CppSystem.Object>(5);
|
var list = new Il2CppSystem.Collections.Generic.List<Il2CppSystem.Object>(5);
|
||||||
list.Add("one");
|
list.Add("one");
|
||||||
list.Add("two");
|
list.Add("two");
|
||||||
IL2CPP_IList = list.TryCast<Il2CppSystem.Collections.IList>();
|
IL2CPP_IList = list.TryCast<Il2CppSystem.Collections.IList>();
|
||||||
|
|
||||||
|
ExplorerCore.Log($"IL2CPP 5: Il2Cpp List of strings");
|
||||||
IL2CPP_ListString = new Il2CppSystem.Collections.Generic.List<string>();
|
IL2CPP_ListString = new Il2CppSystem.Collections.Generic.List<string>();
|
||||||
IL2CPP_ListString.Add("hello,");
|
IL2CPP_ListString.Add("hello,");
|
||||||
IL2CPP_ListString.Add("world!");
|
IL2CPP_ListString.Add("world!");
|
||||||
|
|
||||||
|
ExplorerCore.Log($"IL2CPP 6: Il2Cpp HashSet of strings");
|
||||||
IL2CPP_HashSet = new Il2CppSystem.Collections.Generic.HashSet<string>();
|
IL2CPP_HashSet = new Il2CppSystem.Collections.Generic.HashSet<string>();
|
||||||
IL2CPP_HashSet.Add("one");
|
IL2CPP_HashSet.Add("one");
|
||||||
IL2CPP_HashSet.Add("two");
|
IL2CPP_HashSet.Add("two");
|
||||||
|
|
||||||
|
ExplorerCore.Log($"IL2CPP 7: Dictionary of Il2Cpp String and Il2Cpp Object");
|
||||||
CppBoxedDict = new Dictionary<Il2CppSystem.String, Il2CppSystem.Object>();
|
CppBoxedDict = new Dictionary<Il2CppSystem.String, Il2CppSystem.Object>();
|
||||||
CppBoxedDict.Add("1", new Il2CppSystem.Int32 { m_value = 1 }.BoxIl2CppObject());
|
CppBoxedDict.Add("1", new Il2CppSystem.Int32 { m_value = 1 }.BoxIl2CppObject());
|
||||||
CppBoxedDict.Add("2", new Il2CppSystem.Int32 { m_value = 2 }.BoxIl2CppObject());
|
CppBoxedDict.Add("2", new Il2CppSystem.Int32 { m_value = 2 }.BoxIl2CppObject());
|
||||||
CppBoxedDict.Add("3", new Il2CppSystem.Int32 { m_value = 3 }.BoxIl2CppObject());
|
CppBoxedDict.Add("3", new Il2CppSystem.Int32 { m_value = 3 }.BoxIl2CppObject());
|
||||||
CppBoxedDict.Add("4", new Il2CppSystem.Int32 { m_value = 4 }.BoxIl2CppObject());
|
CppBoxedDict.Add("4", new Il2CppSystem.Int32 { m_value = 4 }.BoxIl2CppObject());
|
||||||
|
|
||||||
cppDecimal = new Il2CppSystem.Decimal(1f);
|
ExplorerCore.Log($"IL2CPP 8: List of boxed Il2Cpp Objects");
|
||||||
cppDecimalBoxed = new Il2CppSystem.Decimal(1f).BoxIl2CppObject();
|
|
||||||
cppVector3Boxed = Vector3.down.BoxIl2CppObject();
|
|
||||||
|
|
||||||
|
|
||||||
IL2CPP_listOfBoxedObjects = new List<Il2CppSystem.Object>();
|
IL2CPP_listOfBoxedObjects = new List<Il2CppSystem.Object>();
|
||||||
IL2CPP_listOfBoxedObjects.Add((Il2CppSystem.String)"boxedString");
|
IL2CPP_listOfBoxedObjects.Add((Il2CppSystem.String)"boxedString");
|
||||||
IL2CPP_listOfBoxedObjects.Add(new Il2CppSystem.Int32 { m_value = 5 }.BoxIl2CppObject());
|
IL2CPP_listOfBoxedObjects.Add(new Il2CppSystem.Int32 { m_value = 5 }.BoxIl2CppObject());
|
||||||
IL2CPP_listOfBoxedObjects.Add(Color.red.BoxIl2CppObject());
|
IL2CPP_listOfBoxedObjects.Add(Color.red.BoxIl2CppObject());
|
||||||
|
// boxed enum test
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var cppType = Il2CppType.Of<CameraClearFlags>();
|
var cppType = Il2CppType.Of<CameraClearFlags>();
|
||||||
@ -283,9 +208,10 @@ namespace UnityExplorer.Tests
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ExplorerCore.LogWarning($"Test fail: {ex}");
|
ExplorerCore.LogWarning($"Boxed enum test fail: {ex}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ExplorerCore.Log($"IL2CPP 9: Il2Cpp struct array of ints");
|
||||||
IL2CPP_structArray = new UnhollowerBaseLib.Il2CppStructArray<int>(5);
|
IL2CPP_structArray = new UnhollowerBaseLib.Il2CppStructArray<int>(5);
|
||||||
IL2CPP_structArray[0] = 0;
|
IL2CPP_structArray[0] = 0;
|
||||||
IL2CPP_structArray[1] = 1;
|
IL2CPP_structArray[1] = 1;
|
||||||
@ -293,24 +219,21 @@ namespace UnityExplorer.Tests
|
|||||||
IL2CPP_structArray[3] = 3;
|
IL2CPP_structArray[3] = 3;
|
||||||
IL2CPP_structArray[4] = 4;
|
IL2CPP_structArray[4] = 4;
|
||||||
|
|
||||||
IL2CPP_stringArray = new UnhollowerBaseLib.Il2CppStringArray(2);
|
ExplorerCore.Log($"IL2CPP 10: Il2Cpp reference array of boxed objects");
|
||||||
IL2CPP_stringArray[0] = "hello, ";
|
|
||||||
IL2CPP_stringArray[1] = "world!";
|
|
||||||
|
|
||||||
IL2CPP_ReferenceArray = new UnhollowerBaseLib.Il2CppReferenceArray<Il2CppSystem.Object>(3);
|
IL2CPP_ReferenceArray = new UnhollowerBaseLib.Il2CppReferenceArray<Il2CppSystem.Object>(3);
|
||||||
IL2CPP_ReferenceArray[0] = new Il2CppSystem.Int32 { m_value = 5 }.BoxIl2CppObject();
|
IL2CPP_ReferenceArray[0] = new Il2CppSystem.Int32 { m_value = 5 }.BoxIl2CppObject();
|
||||||
IL2CPP_ReferenceArray[1] = null;
|
IL2CPP_ReferenceArray[1] = null;
|
||||||
IL2CPP_ReferenceArray[2] = (Il2CppSystem.String)"whats up";
|
IL2CPP_ReferenceArray[2] = (Il2CppSystem.String)"whats up";
|
||||||
|
|
||||||
|
ExplorerCore.Log($"IL2CPP 11: Misc il2cpp members");
|
||||||
cppBoxedInt = new Il2CppSystem.Int32() { m_value = 5 }.BoxIl2CppObject();
|
cppBoxedInt = new Il2CppSystem.Int32() { m_value = 5 }.BoxIl2CppObject();
|
||||||
cppInt = new Il2CppSystem.Int32 { m_value = 420 };
|
cppInt = new Il2CppSystem.Int32 { m_value = 420 };
|
||||||
|
cppDecimal = new Il2CppSystem.Decimal(1f);
|
||||||
|
cppDecimalBoxed = new Il2CppSystem.Decimal(1f).BoxIl2CppObject();
|
||||||
|
cppVector3Boxed = Vector3.down.BoxIl2CppObject();
|
||||||
|
|
||||||
cppHashset = new Il2CppSystem.Collections.Hashtable();
|
ExplorerCore.Log($"Finished Init_Il2Cpp");
|
||||||
cppHashset.Add("key1", "itemOne");
|
}
|
||||||
cppHashset.Add("key2", "itemTwo");
|
|
||||||
cppHashset.Add("key3", "itemThree");
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ namespace UnityExplorer
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool ContainsIgnoreCase(this string _this, string s)
|
public static bool ContainsIgnoreCase(this string _this, string s)
|
||||||
{
|
{
|
||||||
return ParseUtility.en_US.CompareInfo.IndexOf(_this, s, CompareOptions.IgnoreCase) >= 0;
|
return CultureInfo.CurrentCulture.CompareInfo.IndexOf(_this, s, CompareOptions.IgnoreCase) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -10,8 +10,6 @@ namespace UnityExplorer
|
|||||||
{
|
{
|
||||||
public static class ParseUtility
|
public static class ParseUtility
|
||||||
{
|
{
|
||||||
public static CultureInfo en_US = new CultureInfo("en-US");
|
|
||||||
|
|
||||||
private static readonly HashSet<Type> nonPrimitiveTypes = new HashSet<Type>
|
private static readonly HashSet<Type> nonPrimitiveTypes = new HashSet<Type>
|
||||||
{
|
{
|
||||||
typeof(string),
|
typeof(string),
|
||||||
@ -19,20 +17,18 @@ namespace UnityExplorer
|
|||||||
typeof(DateTime),
|
typeof(DateTime),
|
||||||
};
|
};
|
||||||
|
|
||||||
public const string NUMBER_FORMAT = "0.####";
|
// Helper for formatting float/double/decimal numbers to maximum of 4 decimal points.
|
||||||
|
// And also for formatting a sequence of those numbers, ie a Vector3, Color etc
|
||||||
|
|
||||||
|
public static readonly string NumberFormatString = $"0.####";
|
||||||
private static readonly Dictionary<int, string> numSequenceStrings = new Dictionary<int, string>();
|
private static readonly Dictionary<int, string> numSequenceStrings = new Dictionary<int, string>();
|
||||||
|
|
||||||
// Helper for formatting float/double/decimal numbers to maximum of 4 decimal points.
|
|
||||||
public static string FormatDecimalSequence(params object[] numbers)
|
public static string FormatDecimalSequence(params object[] numbers)
|
||||||
{
|
{
|
||||||
if (numbers.Length <= 0)
|
if (numbers.Length <= 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
int count = numbers.Length;
|
return string.Format(CultureInfo.CurrentCulture, GetSequenceFormatString(numbers.Length), numbers);
|
||||||
var formatString = GetSequenceFormatString(count);
|
|
||||||
|
|
||||||
return string.Format(en_US, formatString, numbers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetSequenceFormatString(int count)
|
public static string GetSequenceFormatString(int count)
|
||||||
@ -46,19 +42,19 @@ namespace UnityExplorer
|
|||||||
string[] strings = new string[count];
|
string[] strings = new string[count];
|
||||||
|
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
strings[i] = $"{{{i}:{NUMBER_FORMAT}}}";
|
strings[i] = $"{{{i}:{NumberFormatString}}}";
|
||||||
|
|
||||||
string s = string.Join(", ", strings);
|
string ret = string.Join(" ", strings);
|
||||||
|
numSequenceStrings.Add(count, ret);
|
||||||
numSequenceStrings.Add(count, s);
|
return ret;
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Main parsing API
|
||||||
|
|
||||||
public static bool CanParse(Type type)
|
public static bool CanParse(Type type)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(type.FullName))
|
return !string.IsNullOrEmpty(type?.FullName)
|
||||||
return false;
|
&& (type.IsPrimitive || type.IsEnum || nonPrimitiveTypes.Contains(type) || customTypes.ContainsKey(type.FullName));
|
||||||
return type.IsPrimitive || type.IsEnum || nonPrimitiveTypes.Contains(type) || customTypes.ContainsKey(type.FullName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool TryParse(string input, Type type, out object obj, out Exception parseException)
|
public static bool TryParse(string input, Type type, out object obj, out Exception parseException)
|
||||||
@ -143,7 +139,7 @@ namespace UnityExplorer
|
|||||||
else if (formattedTypes.Contains(type))
|
else if (formattedTypes.Contains(type))
|
||||||
{
|
{
|
||||||
return ReflectionUtility.GetMethodInfo(type, "ToString", new Type[] { typeof(string), typeof(IFormatProvider) })
|
return ReflectionUtility.GetMethodInfo(type, "ToString", new Type[] { typeof(string), typeof(IFormatProvider) })
|
||||||
.Invoke(obj, new object[] { NUMBER_FORMAT, en_US })
|
.Invoke(obj, new object[] { NumberFormatString, CultureInfo.CurrentCulture })
|
||||||
as string;
|
as string;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -166,9 +162,7 @@ namespace UnityExplorer
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (type.IsEnum)
|
if (type.IsEnum)
|
||||||
{
|
|
||||||
typeInputExamples.Add(type.AssemblyQualifiedName, Enum.GetNames(type).First());
|
typeInputExamples.Add(type.AssemblyQualifiedName, Enum.GetNames(type).First());
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var instance = Activator.CreateInstance(type);
|
var instance = Activator.CreateInstance(type);
|
||||||
@ -222,10 +216,10 @@ namespace UnityExplorer
|
|||||||
{
|
{
|
||||||
Vector2 vector = default;
|
Vector2 vector = default;
|
||||||
|
|
||||||
var split = input.Split(',');
|
var split = input.Split(' ');
|
||||||
|
|
||||||
vector.x = float.Parse(split[0].Trim(), en_US);
|
vector.x = float.Parse(split[0].Trim(), CultureInfo.CurrentCulture);
|
||||||
vector.y = float.Parse(split[1].Trim(), en_US);
|
vector.y = float.Parse(split[1].Trim(), CultureInfo.CurrentCulture);
|
||||||
|
|
||||||
return vector;
|
return vector;
|
||||||
}
|
}
|
||||||
@ -244,11 +238,11 @@ namespace UnityExplorer
|
|||||||
{
|
{
|
||||||
Vector3 vector = default;
|
Vector3 vector = default;
|
||||||
|
|
||||||
var split = input.Split(',');
|
var split = input.Split(' ');
|
||||||
|
|
||||||
vector.x = float.Parse(split[0].Trim(), en_US);
|
vector.x = float.Parse(split[0].Trim(), CultureInfo.CurrentCulture);
|
||||||
vector.y = float.Parse(split[1].Trim(), en_US);
|
vector.y = float.Parse(split[1].Trim(), CultureInfo.CurrentCulture);
|
||||||
vector.z = float.Parse(split[2].Trim(), en_US);
|
vector.z = float.Parse(split[2].Trim(), CultureInfo.CurrentCulture);
|
||||||
|
|
||||||
return vector;
|
return vector;
|
||||||
}
|
}
|
||||||
@ -267,12 +261,12 @@ namespace UnityExplorer
|
|||||||
{
|
{
|
||||||
Vector4 vector = default;
|
Vector4 vector = default;
|
||||||
|
|
||||||
var split = input.Split(',');
|
var split = input.Split(' ');
|
||||||
|
|
||||||
vector.x = float.Parse(split[0].Trim(), en_US);
|
vector.x = float.Parse(split[0].Trim(), CultureInfo.CurrentCulture);
|
||||||
vector.y = float.Parse(split[1].Trim(), en_US);
|
vector.y = float.Parse(split[1].Trim(), CultureInfo.CurrentCulture);
|
||||||
vector.z = float.Parse(split[2].Trim(), en_US);
|
vector.z = float.Parse(split[2].Trim(), CultureInfo.CurrentCulture);
|
||||||
vector.w = float.Parse(split[3].Trim(), en_US);
|
vector.w = float.Parse(split[3].Trim(), CultureInfo.CurrentCulture);
|
||||||
|
|
||||||
return vector;
|
return vector;
|
||||||
}
|
}
|
||||||
@ -291,22 +285,22 @@ namespace UnityExplorer
|
|||||||
{
|
{
|
||||||
Vector3 vector = default;
|
Vector3 vector = default;
|
||||||
|
|
||||||
var split = input.Split(',');
|
var split = input.Split(' ');
|
||||||
|
|
||||||
if (split.Length == 4)
|
if (split.Length == 4)
|
||||||
{
|
{
|
||||||
Quaternion quat = default;
|
Quaternion quat = default;
|
||||||
quat.x = float.Parse(split[0].Trim(), en_US);
|
quat.x = float.Parse(split[0].Trim(), CultureInfo.CurrentCulture);
|
||||||
quat.y = float.Parse(split[1].Trim(), en_US);
|
quat.y = float.Parse(split[1].Trim(), CultureInfo.CurrentCulture);
|
||||||
quat.z = float.Parse(split[2].Trim(), en_US);
|
quat.z = float.Parse(split[2].Trim(), CultureInfo.CurrentCulture);
|
||||||
quat.w = float.Parse(split[3].Trim(), en_US);
|
quat.w = float.Parse(split[3].Trim(), CultureInfo.CurrentCulture);
|
||||||
return quat;
|
return quat;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vector.x = float.Parse(split[0].Trim(), en_US);
|
vector.x = float.Parse(split[0].Trim(), CultureInfo.CurrentCulture);
|
||||||
vector.y = float.Parse(split[1].Trim(), en_US);
|
vector.y = float.Parse(split[1].Trim(), CultureInfo.CurrentCulture);
|
||||||
vector.z = float.Parse(split[2].Trim(), en_US);
|
vector.z = float.Parse(split[2].Trim(), CultureInfo.CurrentCulture);
|
||||||
return Quaternion.Euler(vector);
|
return Quaternion.Euler(vector);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -327,12 +321,12 @@ namespace UnityExplorer
|
|||||||
{
|
{
|
||||||
Rect rect = default;
|
Rect rect = default;
|
||||||
|
|
||||||
var split = input.Split(',');
|
var split = input.Split(' ');
|
||||||
|
|
||||||
rect.x = float.Parse(split[0].Trim(), en_US);
|
rect.x = float.Parse(split[0].Trim(), CultureInfo.CurrentCulture);
|
||||||
rect.y = float.Parse(split[1].Trim(), en_US);
|
rect.y = float.Parse(split[1].Trim(), CultureInfo.CurrentCulture);
|
||||||
rect.width = float.Parse(split[2].Trim(), en_US);
|
rect.width = float.Parse(split[2].Trim(), CultureInfo.CurrentCulture);
|
||||||
rect.height = float.Parse(split[3].Trim(), en_US);
|
rect.height = float.Parse(split[3].Trim(), CultureInfo.CurrentCulture);
|
||||||
|
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
@ -351,13 +345,13 @@ namespace UnityExplorer
|
|||||||
{
|
{
|
||||||
Color color = default;
|
Color color = default;
|
||||||
|
|
||||||
var split = input.Split(',');
|
var split = input.Split(' ');
|
||||||
|
|
||||||
color.r = float.Parse(split[0].Trim(), en_US);
|
color.r = float.Parse(split[0].Trim(), CultureInfo.CurrentCulture);
|
||||||
color.g = float.Parse(split[1].Trim(), en_US);
|
color.g = float.Parse(split[1].Trim(), CultureInfo.CurrentCulture);
|
||||||
color.b = float.Parse(split[2].Trim(), en_US);
|
color.b = float.Parse(split[2].Trim(), CultureInfo.CurrentCulture);
|
||||||
if (split.Length > 3)
|
if (split.Length > 3)
|
||||||
color.a = float.Parse(split[3].Trim(), en_US);
|
color.a = float.Parse(split[3].Trim(), CultureInfo.CurrentCulture);
|
||||||
else
|
else
|
||||||
color.a = 1;
|
color.a = 1;
|
||||||
|
|
||||||
@ -378,13 +372,13 @@ namespace UnityExplorer
|
|||||||
{
|
{
|
||||||
Color32 color = default;
|
Color32 color = default;
|
||||||
|
|
||||||
var split = input.Split(',');
|
var split = input.Split(' ');
|
||||||
|
|
||||||
color.r = byte.Parse(split[0].Trim(), en_US);
|
color.r = byte.Parse(split[0].Trim(), CultureInfo.CurrentCulture);
|
||||||
color.g = byte.Parse(split[1].Trim(), en_US);
|
color.g = byte.Parse(split[1].Trim(), CultureInfo.CurrentCulture);
|
||||||
color.b = byte.Parse(split[2].Trim(), en_US);
|
color.b = byte.Parse(split[2].Trim(), CultureInfo.CurrentCulture);
|
||||||
if (split.Length > 3)
|
if (split.Length > 3)
|
||||||
color.a = byte.Parse(split[3].Trim(), en_US);
|
color.a = byte.Parse(split[3].Trim(), CultureInfo.CurrentCulture);
|
||||||
else
|
else
|
||||||
color.a = 255;
|
color.a = 255;
|
||||||
|
|
||||||
@ -397,7 +391,7 @@ namespace UnityExplorer
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
// ints, this is fine
|
// ints, this is fine
|
||||||
return $"{color.r}, {color.g}, {color.b}, {color.a}";
|
return $"{color.r} {color.g} {color.b} {color.a}";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Layermask (Int32)
|
// Layermask (Int32)
|
||||||
|
@ -2,9 +2,11 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Events;
|
using UnityEngine.Events;
|
||||||
|
using UnityEngine.UI;
|
||||||
using Object = UnityEngine.Object;
|
using Object = UnityEngine.Object;
|
||||||
|
|
||||||
// Project-wide namespace for accessibility
|
// Project-wide namespace for accessibility
|
||||||
@ -107,5 +109,16 @@ namespace UnityExplorer
|
|||||||
|
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static PropertyInfo onEndEdit;
|
||||||
|
|
||||||
|
public static UnityEvent<string> GetOnEndEdit(this InputField _this)
|
||||||
|
{
|
||||||
|
if (onEndEdit == null)
|
||||||
|
onEndEdit = typeof(InputField).GetProperty("onEndEdit")
|
||||||
|
?? throw new Exception("Could not get InputField.onEndEdit property!");
|
||||||
|
|
||||||
|
return onEndEdit.GetValue(_this, null).TryCast<UnityEvent<string>>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,8 @@ using UnityExplorer.Core.Input;
|
|||||||
using UnityExplorer.Core.Runtime;
|
using UnityExplorer.Core.Runtime;
|
||||||
using UnityExplorer.Tests;
|
using UnityExplorer.Tests;
|
||||||
using UnityExplorer.UI;
|
using UnityExplorer.UI;
|
||||||
using UnityExplorer.UI.Inspectors;
|
using UnityExplorer.Inspectors;
|
||||||
using UnityExplorer.UI.ObjectExplorer;
|
using UnityExplorer.ObjectExplorer;
|
||||||
using UnityExplorer.UI.Panels;
|
using UnityExplorer.UI.Panels;
|
||||||
|
|
||||||
namespace UnityExplorer
|
namespace UnityExplorer
|
||||||
@ -20,13 +20,15 @@ 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.1.0";
|
public const string VERSION = "4.2.0";
|
||||||
public const string AUTHOR = "Sinai";
|
public const string AUTHOR = "Sinai";
|
||||||
public const string GUID = "com.sinai.unityexplorer";
|
public const string GUID = "com.sinai.unityexplorer";
|
||||||
|
|
||||||
public static IExplorerLoader Loader { get; private set; }
|
public static IExplorerLoader Loader { get; private set; }
|
||||||
public static RuntimeContext Context { get; internal set; }
|
public static RuntimeContext Context { get; internal set; }
|
||||||
|
|
||||||
|
public static HarmonyLib.Harmony Harmony { get; } = new HarmonyLib.Harmony(GUID);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initialize UnityExplorer with the provided Loader implementation.
|
/// Initialize UnityExplorer with the provided Loader implementation.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -47,10 +49,9 @@ namespace UnityExplorer
|
|||||||
Directory.CreateDirectory(Loader.ExplorerFolder);
|
Directory.CreateDirectory(Loader.ExplorerFolder);
|
||||||
|
|
||||||
ConfigManager.Init(Loader.ConfigHandler);
|
ConfigManager.Init(Loader.ConfigHandler);
|
||||||
|
|
||||||
ReflectionUtility.Init();
|
ReflectionUtility.Init();
|
||||||
|
|
||||||
RuntimeProvider.Init();
|
RuntimeProvider.Init();
|
||||||
|
|
||||||
SceneHandler.Init();
|
SceneHandler.Init();
|
||||||
InputManager.Init();
|
InputManager.Init();
|
||||||
|
|
||||||
@ -103,7 +104,7 @@ namespace UnityExplorer
|
|||||||
RuntimeProvider.Instance.ProcessOnPostRender();
|
RuntimeProvider.Instance.ProcessOnPostRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region LOGGING
|
#region LOGGING
|
||||||
|
|
||||||
public static void Log(object message)
|
public static void Log(object message)
|
||||||
=> Log(message, LogType.Log);
|
=> Log(message, LogType.Log);
|
||||||
@ -146,6 +147,6 @@ namespace UnityExplorer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,12 +6,13 @@ using System.Text;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.Core.Input;
|
using UnityExplorer.Core.Input;
|
||||||
|
using UnityExplorer.UI;
|
||||||
using UnityExplorer.UI.Models;
|
using UnityExplorer.UI.Models;
|
||||||
using UnityExplorer.UI.Panels;
|
using UnityExplorer.UI.Panels;
|
||||||
using UnityExplorer.UI.Widgets;
|
using UnityExplorer.UI.Widgets;
|
||||||
using UnityExplorer.UI.Widgets.AutoComplete;
|
using UnityExplorer.UI.Widgets.AutoComplete;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.Inspectors
|
namespace UnityExplorer.Inspectors
|
||||||
{
|
{
|
||||||
public class GameObjectInspector : InspectorBase
|
public class GameObjectInspector : InspectorBase
|
||||||
{
|
{
|
||||||
@ -147,32 +148,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 +189,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 +200,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 +220,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
|
||||||
{
|
{
|
@ -4,9 +4,10 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
using UnityExplorer.UI;
|
||||||
using UnityExplorer.UI.Widgets;
|
using UnityExplorer.UI.Widgets;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.Inspectors
|
namespace UnityExplorer.Inspectors
|
||||||
{
|
{
|
||||||
public class ComponentCell : ButtonCell
|
public class ComponentCell : ButtonCell
|
||||||
{
|
{
|
@ -5,7 +5,7 @@ using System.Text;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityExplorer.UI.Widgets;
|
using UnityExplorer.UI.Widgets;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.Inspectors
|
namespace UnityExplorer.Inspectors
|
||||||
{
|
{
|
||||||
public class ComponentList : ButtonListHandler<Component, ComponentCell>
|
public class ComponentList : ButtonListHandler<Component, ComponentCell>
|
||||||
{
|
{
|
@ -5,8 +5,9 @@ using System.Text;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.Core.Input;
|
using UnityExplorer.Core.Input;
|
||||||
|
using UnityExplorer.UI;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.Inspectors
|
namespace UnityExplorer.Inspectors
|
||||||
{
|
{
|
||||||
public class GameObjectControls
|
public class GameObjectControls
|
||||||
{
|
{
|
||||||
@ -234,7 +235,7 @@ namespace UnityExplorer.UI.Inspectors
|
|||||||
|
|
||||||
private void OnExploreButtonClicked()
|
private void OnExploreButtonClicked()
|
||||||
{
|
{
|
||||||
var panel = UIManager.GetPanel<Panels.ObjectExplorerPanel>(UIManager.Panels.ObjectExplorer);
|
var panel = UIManager.GetPanel<UI.Panels.ObjectExplorerPanel>(UIManager.Panels.ObjectExplorer);
|
||||||
panel.SceneExplorer.JumpToTransform(this.Parent.GOTarget.transform);
|
panel.SceneExplorer.JumpToTransform(this.Parent.GOTarget.transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -468,7 +469,7 @@ namespace UnityExplorer.UI.Inspectors
|
|||||||
//UIFactory.SetLayoutElement(pathApplyBtn.Component.gameObject, minHeight: 25, minWidth: 120);
|
//UIFactory.SetLayoutElement(pathApplyBtn.Component.gameObject, minHeight: 25, minWidth: 120);
|
||||||
//pathApplyBtn.OnClick += () => { OnPathEndEdit(PathInput.Text); };
|
//pathApplyBtn.OnClick += () => { OnPathEndEdit(PathInput.Text); };
|
||||||
|
|
||||||
PathInput.Component.onEndEdit.AddListener((string val) => { OnPathEndEdit(val); });
|
PathInput.Component.GetOnEndEdit().AddListener((string val) => { OnPathEndEdit(val); });
|
||||||
|
|
||||||
// Title and update row
|
// Title and update row
|
||||||
|
|
||||||
@ -484,7 +485,7 @@ namespace UnityExplorer.UI.Inspectors
|
|||||||
NameInput = UIFactory.CreateInputField(titleRow, "NameInput", "untitled");
|
NameInput = UIFactory.CreateInputField(titleRow, "NameInput", "untitled");
|
||||||
UIFactory.SetLayoutElement(NameInput.Component.gameObject, minHeight: 30, minWidth: 100, flexibleWidth: 9999);
|
UIFactory.SetLayoutElement(NameInput.Component.gameObject, minHeight: 30, minWidth: 100, flexibleWidth: 9999);
|
||||||
NameInput.Component.textComponent.fontSize = 15;
|
NameInput.Component.textComponent.fontSize = 15;
|
||||||
NameInput.Component.onEndEdit.AddListener((string val) => { OnNameEndEdit(val); });
|
NameInput.Component.GetOnEndEdit().AddListener((string val) => { OnNameEndEdit(val); });
|
||||||
|
|
||||||
// second row (toggles, instanceID, tag, buttons)
|
// second row (toggles, instanceID, tag, buttons)
|
||||||
|
|
||||||
@ -521,7 +522,7 @@ namespace UnityExplorer.UI.Inspectors
|
|||||||
TagInput = UIFactory.CreateInputField(secondRow, "TagInput", "none");
|
TagInput = UIFactory.CreateInputField(secondRow, "TagInput", "none");
|
||||||
UIFactory.SetLayoutElement(TagInput.Component.gameObject, minHeight: 25, minWidth: 100, flexibleWidth: 999);
|
UIFactory.SetLayoutElement(TagInput.Component.gameObject, minHeight: 25, minWidth: 100, flexibleWidth: 999);
|
||||||
TagInput.Component.textComponent.color = Color.white;
|
TagInput.Component.textComponent.color = Color.white;
|
||||||
TagInput.Component.onEndEdit.AddListener((string val) => { OnTagEndEdit(val); });
|
TagInput.Component.GetOnEndEdit().AddListener((string val) => { OnTagEndEdit(val); });
|
||||||
|
|
||||||
// Instantiate
|
// Instantiate
|
||||||
var instantiateBtn = UIFactory.CreateButton(secondRow, "InstantiateBtn", "Instantiate", new Color(0.2f, 0.2f, 0.2f));
|
var instantiateBtn = UIFactory.CreateButton(secondRow, "InstantiateBtn", "Instantiate", new Color(0.2f, 0.2f, 0.2f));
|
||||||
@ -644,7 +645,7 @@ namespace UnityExplorer.UI.Inspectors
|
|||||||
var inputField = UIFactory.CreateInputField(rowObj, "InputField", "...");
|
var inputField = UIFactory.CreateInputField(rowObj, "InputField", "...");
|
||||||
UIFactory.SetLayoutElement(inputField.Component.gameObject, minHeight: 25, minWidth: 100, flexibleWidth: 999);
|
UIFactory.SetLayoutElement(inputField.Component.gameObject, minHeight: 25, minWidth: 100, flexibleWidth: 999);
|
||||||
|
|
||||||
inputField.Component.onEndEdit.AddListener((string value) => { OnTransformInputEndEdit(type, value); });
|
inputField.Component.GetOnEndEdit().AddListener((string value) => { OnTransformInputEndEdit(type, value); });
|
||||||
|
|
||||||
var control = new TransformControl(type, inputField);
|
var control = new TransformControl(type, inputField);
|
||||||
|
|
@ -11,7 +11,7 @@ using UnityExplorer.Core.Runtime;
|
|||||||
using UnityExplorer.UI;
|
using UnityExplorer.UI;
|
||||||
using UnityExplorer.UI.Panels;
|
using UnityExplorer.UI.Panels;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.Inspectors
|
namespace UnityExplorer.Inspectors
|
||||||
{
|
{
|
||||||
public enum MouseInspectMode
|
public enum MouseInspectMode
|
||||||
{
|
{
|
||||||
@ -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();
|
||||||
|
|
@ -4,10 +4,11 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
using UnityExplorer.UI;
|
||||||
using UnityExplorer.UI.Models;
|
using UnityExplorer.UI.Models;
|
||||||
using UnityExplorer.UI.Panels;
|
using UnityExplorer.UI.Panels;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.Inspectors
|
namespace UnityExplorer.Inspectors
|
||||||
{
|
{
|
||||||
public abstract class InspectorBase : IPooledObject
|
public abstract class InspectorBase : IPooledObject
|
||||||
{
|
{
|
@ -5,8 +5,8 @@ using System.Text;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.UI;
|
using UnityExplorer.UI;
|
||||||
using UnityExplorer.UI.CacheObject;
|
using UnityExplorer.CacheObject;
|
||||||
using UnityExplorer.UI.Inspectors;
|
using UnityExplorer.Inspectors;
|
||||||
using UnityExplorer.UI.Models;
|
using UnityExplorer.UI.Models;
|
||||||
using UnityExplorer.UI.Panels;
|
using UnityExplorer.UI.Panels;
|
||||||
|
|
@ -4,10 +4,11 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
using UnityExplorer.UI;
|
||||||
using UnityExplorer.UI.Models;
|
using UnityExplorer.UI.Models;
|
||||||
using UnityExplorer.UI.Widgets;
|
using UnityExplorer.UI.Widgets;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.Inspectors
|
namespace UnityExplorer.Inspectors
|
||||||
{
|
{
|
||||||
public class InspectorTab : IPooledObject
|
public class InspectorTab : IPooledObject
|
||||||
{
|
{
|
@ -10,12 +10,13 @@ using UnityEngine;
|
|||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.Core.Config;
|
using UnityExplorer.Core.Config;
|
||||||
using UnityExplorer.Core.Runtime;
|
using UnityExplorer.Core.Runtime;
|
||||||
using UnityExplorer.UI.CacheObject;
|
using UnityExplorer.CacheObject;
|
||||||
using UnityExplorer.UI.CacheObject.Views;
|
using UnityExplorer.CacheObject.Views;
|
||||||
using UnityExplorer.UI.Panels;
|
using UnityExplorer.UI.Panels;
|
||||||
using UnityExplorer.UI.Widgets;
|
using UnityExplorer.UI.Widgets;
|
||||||
|
using UnityExplorer.UI;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.Inspectors
|
namespace UnityExplorer.Inspectors
|
||||||
{
|
{
|
||||||
public class ReflectionInspector : InspectorBase, ICellPoolDataSource<CacheMemberCell>, ICacheObjectController
|
public class ReflectionInspector : InspectorBase, ICellPoolDataSource<CacheMemberCell>, ICacheObjectController
|
||||||
{
|
{
|
||||||
@ -54,6 +55,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 +75,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 +308,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)
|
||||||
@ -342,7 +340,7 @@ namespace UnityExplorer.UI.Inspectors
|
|||||||
|
|
||||||
ConstructUnityObjectRow();
|
ConstructUnityObjectRow();
|
||||||
|
|
||||||
mainContentHolder = UIFactory.CreateVerticalGroup(UIRoot, "MemberHolder", false, false, true, true, 5, new Vector4(2,2,2,2),
|
mainContentHolder = UIFactory.CreateVerticalGroup(UIRoot, "MemberHolder", false, false, true, true, 5, new Vector4(2, 2, 2, 2),
|
||||||
new Color(0.12f, 0.12f, 0.12f));
|
new Color(0.12f, 0.12f, 0.12f));
|
||||||
UIFactory.SetLayoutElement(mainContentHolder, flexibleWidth: 9999, flexibleHeight: 9999);
|
UIFactory.SetLayoutElement(mainContentHolder, flexibleWidth: 9999, flexibleHeight: 9999);
|
||||||
|
|
||||||
@ -352,7 +350,7 @@ namespace UnityExplorer.UI.Inspectors
|
|||||||
|
|
||||||
// Member scroll pool
|
// Member scroll pool
|
||||||
|
|
||||||
var memberBorder = UIFactory.CreateVerticalGroup(mainContentHolder, "ScrollPoolHolder", false, false, true, true, padding: new Vector4(2,2,2,2),
|
var memberBorder = UIFactory.CreateVerticalGroup(mainContentHolder, "ScrollPoolHolder", false, false, true, true, padding: new Vector4(2, 2, 2, 2),
|
||||||
bgColor: new Color(0.05f, 0.05f, 0.05f));
|
bgColor: new Color(0.05f, 0.05f, 0.05f));
|
||||||
UIFactory.SetLayoutElement(memberBorder, flexibleWidth: 9999, flexibleHeight: 9999);
|
UIFactory.SetLayoutElement(memberBorder, flexibleWidth: 9999, flexibleHeight: 9999);
|
||||||
|
|
||||||
@ -617,12 +615,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);
|
||||||
}
|
}
|
@ -1,119 +0,0 @@
|
|||||||
#if BIE
|
|
||||||
using BepInEx;
|
|
||||||
using BepInEx.Logging;
|
|
||||||
using HarmonyLib;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using UnityExplorer.Core.Config;
|
|
||||||
using UnityExplorer.Loader.BIE;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityExplorer.Core;
|
|
||||||
using UnityEngine.EventSystems;
|
|
||||||
using UnityExplorer.Core.Input;
|
|
||||||
#if CPP
|
|
||||||
using BepInEx.IL2CPP;
|
|
||||||
using UnhollowerRuntimeLib;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace UnityExplorer
|
|
||||||
{
|
|
||||||
[BepInPlugin(ExplorerCore.GUID, "UnityExplorer", ExplorerCore.VERSION)]
|
|
||||||
|
|
||||||
public class ExplorerBepInPlugin :
|
|
||||||
#if MONO
|
|
||||||
BaseUnityPlugin
|
|
||||||
#else
|
|
||||||
BasePlugin
|
|
||||||
#endif
|
|
||||||
, IExplorerLoader
|
|
||||||
{
|
|
||||||
public static ExplorerBepInPlugin Instance;
|
|
||||||
|
|
||||||
public ManualLogSource LogSource
|
|
||||||
#if MONO
|
|
||||||
=> Logger;
|
|
||||||
#else
|
|
||||||
=> Log;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
public ConfigHandler ConfigHandler => _configHandler;
|
|
||||||
private BepInExConfigHandler _configHandler;
|
|
||||||
|
|
||||||
public Harmony HarmonyInstance => s_harmony;
|
|
||||||
private static readonly Harmony s_harmony = new Harmony(ExplorerCore.GUID);
|
|
||||||
|
|
||||||
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> OnLogWarning => LogSource.LogWarning;
|
|
||||||
public Action<object> OnLogError => LogSource.LogError;
|
|
||||||
|
|
||||||
// Init common to Mono and Il2Cpp
|
|
||||||
internal void UniversalInit()
|
|
||||||
{
|
|
||||||
Instance = this;
|
|
||||||
_configHandler = new BepInExConfigHandler();
|
|
||||||
ExplorerCore.Init(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if MONO // Mono
|
|
||||||
internal void Awake()
|
|
||||||
{
|
|
||||||
UniversalInit();
|
|
||||||
}
|
|
||||||
|
|
||||||
#else // Il2Cpp
|
|
||||||
public override void Load()
|
|
||||||
{
|
|
||||||
UniversalInit();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
public void SetupCursorPatches()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
this.HarmonyInstance.PatchAll();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
ExplorerCore.Log($"Exception setting up Harmony patches:\r\n{ex.ReflectionExToString()}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch(typeof(EventSystem), "current", MethodType.Setter)]
|
|
||||||
public class PATCH_EventSystem_current
|
|
||||||
{
|
|
||||||
[HarmonyPrefix]
|
|
||||||
public static void Prefix_EventSystem_set_current(ref EventSystem value)
|
|
||||||
{
|
|
||||||
CursorUnlocker.Prefix_EventSystem_set_current(ref value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch(typeof(Cursor), "lockState", MethodType.Setter)]
|
|
||||||
public class PATCH_Cursor_lockState
|
|
||||||
{
|
|
||||||
[HarmonyPrefix]
|
|
||||||
public static void Prefix_set_lockState(ref CursorLockMode value)
|
|
||||||
{
|
|
||||||
CursorUnlocker.Prefix_set_lockState(ref value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch(typeof(Cursor), "visible", MethodType.Setter)]
|
|
||||||
public class PATCH_Cursor_visible
|
|
||||||
{
|
|
||||||
[HarmonyPrefix]
|
|
||||||
public static void Prefix_set_visible(ref bool value)
|
|
||||||
{
|
|
||||||
CursorUnlocker.Prefix_set_visible(ref value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -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) =>
|
||||||
{
|
{
|
75
src/Loader/BepInEx/ExplorerBepInPlugin.cs
Normal file
75
src/Loader/BepInEx/ExplorerBepInPlugin.cs
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
#if BIE
|
||||||
|
using BepInEx;
|
||||||
|
using BepInEx.Logging;
|
||||||
|
using HarmonyLib;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.EventSystems;
|
||||||
|
using UnityExplorer.Core;
|
||||||
|
using UnityExplorer.Core.Config;
|
||||||
|
using UnityExplorer.Core.Input;
|
||||||
|
using UnityExplorer.Loader.BIE;
|
||||||
|
#if CPP
|
||||||
|
using BepInEx.IL2CPP;
|
||||||
|
using UnhollowerRuntimeLib;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace UnityExplorer
|
||||||
|
{
|
||||||
|
[BepInPlugin(ExplorerCore.GUID, "UnityExplorer", ExplorerCore.VERSION)]
|
||||||
|
|
||||||
|
public class ExplorerBepInPlugin :
|
||||||
|
#if MONO
|
||||||
|
BaseUnityPlugin
|
||||||
|
#else
|
||||||
|
BasePlugin
|
||||||
|
#endif
|
||||||
|
, IExplorerLoader
|
||||||
|
{
|
||||||
|
public static ExplorerBepInPlugin Instance;
|
||||||
|
|
||||||
|
public ManualLogSource LogSource
|
||||||
|
#if MONO
|
||||||
|
=> Logger;
|
||||||
|
#else
|
||||||
|
=> Log;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public ConfigHandler ConfigHandler => _configHandler;
|
||||||
|
private BepInExConfigHandler _configHandler;
|
||||||
|
|
||||||
|
public Harmony HarmonyInstance => s_harmony;
|
||||||
|
private static readonly Harmony s_harmony = new Harmony(ExplorerCore.GUID);
|
||||||
|
|
||||||
|
public string ExplorerFolder => Path.Combine(Paths.PluginPath, ExplorerCore.NAME);
|
||||||
|
|
||||||
|
public Action<object> OnLogMessage => LogSource.LogMessage;
|
||||||
|
public Action<object> OnLogWarning => LogSource.LogWarning;
|
||||||
|
public Action<object> OnLogError => LogSource.LogError;
|
||||||
|
|
||||||
|
private void Init()
|
||||||
|
{
|
||||||
|
Instance = this;
|
||||||
|
_configHandler = new BepInExConfigHandler();
|
||||||
|
ExplorerCore.Init(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if MONO // Mono
|
||||||
|
internal void Awake()
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
#else // Il2Cpp
|
||||||
|
public override void Load()
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
@ -10,13 +10,10 @@ 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; }
|
||||||
Action<object> OnLogWarning { get; }
|
Action<object> OnLogWarning { get; }
|
||||||
Action<object> OnLogError { get; }
|
Action<object> OnLogError { get; }
|
||||||
|
|
||||||
void SetupCursorPatches();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,87 +0,0 @@
|
|||||||
#if ML
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using MelonLoader;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.EventSystems;
|
|
||||||
using UnityExplorer;
|
|
||||||
using UnityExplorer.Core;
|
|
||||||
using UnityExplorer.Core.Config;
|
|
||||||
using UnityExplorer.Core.Input;
|
|
||||||
using UnityExplorer.Loader.ML;
|
|
||||||
#if ML_LEGACY
|
|
||||||
using Harmony;
|
|
||||||
#else
|
|
||||||
using HarmonyLib;
|
|
||||||
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.UNIVERSAL)]
|
|
||||||
#endif
|
|
||||||
|
|
||||||
[assembly: MelonInfo(typeof(ExplorerMelonMod), ExplorerCore.NAME, ExplorerCore.VERSION, ExplorerCore.AUTHOR)]
|
|
||||||
[assembly: MelonGame(null, null)]
|
|
||||||
[assembly: MelonColor(ConsoleColor.DarkCyan)]
|
|
||||||
|
|
||||||
namespace UnityExplorer
|
|
||||||
{
|
|
||||||
public class ExplorerMelonMod : MelonMod, IExplorerLoader
|
|
||||||
{
|
|
||||||
public static ExplorerMelonMod Instance;
|
|
||||||
|
|
||||||
public string ExplorerFolder => Path.Combine("Mods", ExplorerCore.NAME);
|
|
||||||
public string ConfigFolder => ExplorerFolder;
|
|
||||||
|
|
||||||
public ConfigHandler ConfigHandler => _configHandler;
|
|
||||||
public MelonLoaderConfigHandler _configHandler;
|
|
||||||
|
|
||||||
public Action<object> OnLogMessage => MelonLogger.Msg;
|
|
||||||
public Action<object> OnLogWarning => MelonLogger.Warning;
|
|
||||||
public Action<object> OnLogError => MelonLogger.Error;
|
|
||||||
|
|
||||||
public override void OnApplicationStart()
|
|
||||||
{
|
|
||||||
Instance = this;
|
|
||||||
_configHandler = new MelonLoaderConfigHandler();
|
|
||||||
|
|
||||||
ExplorerCore.Init(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetupCursorPatches()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
PrefixProperty(typeof(Cursor),
|
|
||||||
"lockState",
|
|
||||||
new HarmonyMethod(typeof(CursorUnlocker).GetMethod(nameof(CursorUnlocker.Prefix_set_lockState))));
|
|
||||||
|
|
||||||
PrefixProperty(typeof(Cursor),
|
|
||||||
"visible",
|
|
||||||
new HarmonyMethod(typeof(CursorUnlocker).GetMethod(nameof(CursorUnlocker.Prefix_set_visible))));
|
|
||||||
|
|
||||||
PrefixProperty(typeof(EventSystem),
|
|
||||||
"current",
|
|
||||||
new HarmonyMethod(typeof(CursorUnlocker).GetMethod(nameof(CursorUnlocker.Prefix_EventSystem_set_current))));
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
ExplorerCore.Log($"Exception setting up Harmony patches:\r\n{ex.ReflectionExToString()}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PrefixProperty(Type type, string property, HarmonyMethod prefix)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var prop = type.GetProperty(property);
|
|
||||||
#if ML_LEGACY
|
|
||||||
this.Harmony.Patch(prop.GetSetMethod(), prefix: prefix);
|
|
||||||
#else
|
|
||||||
HarmonyInstance.Patch(prop.GetSetMethod(), prefix: prefix);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
ExplorerCore.Log($"Unable to patch {type.Name}.set_{property}: {e.Message}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,206 +0,0 @@
|
|||||||
#if ML
|
|
||||||
|
|
||||||
#if !ML_LEGACY // ML 0.3.1+ config handler
|
|
||||||
|
|
||||||
using MelonLoader;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityExplorer.Core;
|
|
||||||
using UnityExplorer.Core.Config;
|
|
||||||
|
|
||||||
namespace UnityExplorer.Loader.ML
|
|
||||||
{
|
|
||||||
public class MelonLoaderConfigHandler : ConfigHandler
|
|
||||||
{
|
|
||||||
internal const string CTG_NAME = "UnityExplorer";
|
|
||||||
|
|
||||||
internal MelonPreferences_Category prefCategory;
|
|
||||||
|
|
||||||
public override void Init()
|
|
||||||
{
|
|
||||||
prefCategory = MelonPreferences.CreateCategory(CTG_NAME, $"{CTG_NAME} Settings", false, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void LoadConfig()
|
|
||||||
{
|
|
||||||
foreach (var entry in ConfigManager.ConfigElements)
|
|
||||||
{
|
|
||||||
var key = entry.Key;
|
|
||||||
if (prefCategory.GetEntry(key) is MelonPreferences_Entry)
|
|
||||||
{
|
|
||||||
var config = entry.Value;
|
|
||||||
config.BoxedValue = config.GetLoaderConfigValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void RegisterConfigElement<T>(ConfigElement<T> config)
|
|
||||||
{
|
|
||||||
var entry = prefCategory.CreateEntry(config.Name, config.Value, null, config.Description, config.IsInternal, false);
|
|
||||||
|
|
||||||
entry.OnValueChangedUntyped += () =>
|
|
||||||
{
|
|
||||||
if ((entry.Value == null && config.Value == null) || config.Value.Equals(entry.Value))
|
|
||||||
return;
|
|
||||||
|
|
||||||
config.Value = entry.Value;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void SetConfigValue<T>(ConfigElement<T> config, T value)
|
|
||||||
{
|
|
||||||
if (prefCategory.GetEntry<T>(config.Name) is MelonPreferences_Entry<T> entry)
|
|
||||||
{
|
|
||||||
entry.Value = value;
|
|
||||||
//entry.Save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override T GetConfigValue<T>(ConfigElement<T> config)
|
|
||||||
{
|
|
||||||
if (prefCategory.GetEntry<T>(config.Name) is MelonPreferences_Entry<T> entry)
|
|
||||||
return entry.Value;
|
|
||||||
|
|
||||||
return default;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnAnyConfigChanged()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void SaveConfig()
|
|
||||||
{
|
|
||||||
MelonPreferences.Save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#else // ML 0.3.0 config handler
|
|
||||||
|
|
||||||
using MelonLoader;
|
|
||||||
using MelonLoader.Tomlyn.Model;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityExplorer.Core;
|
|
||||||
using UnityExplorer.Core.Config;
|
|
||||||
|
|
||||||
namespace UnityExplorer.Loader.ML
|
|
||||||
{
|
|
||||||
public class MelonLoaderConfigHandler : ConfigHandler
|
|
||||||
{
|
|
||||||
internal const string CTG_NAME = "UnityExplorer";
|
|
||||||
|
|
||||||
internal MelonPreferences_Category prefCategory;
|
|
||||||
|
|
||||||
public override void Init()
|
|
||||||
{
|
|
||||||
prefCategory = MelonPreferences.CreateCategory(CTG_NAME, $"{CTG_NAME} Settings");
|
|
||||||
|
|
||||||
try { MelonPreferences.Mapper.RegisterMapper(KeycodeReader, KeycodeWriter); } catch { }
|
|
||||||
try { MelonPreferences.Mapper.RegisterMapper(AnchorReader, AnchorWriter); } catch { }
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void LoadConfig()
|
|
||||||
{
|
|
||||||
foreach (var entry in ConfigManager.ConfigElements)
|
|
||||||
{
|
|
||||||
var key = entry.Key;
|
|
||||||
if (prefCategory.GetEntry(key) is MelonPreferences_Entry)
|
|
||||||
{
|
|
||||||
var config = entry.Value;
|
|
||||||
config.BoxedValue = config.GetLoaderConfigValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void RegisterConfigElement<T>(ConfigElement<T> config)
|
|
||||||
{
|
|
||||||
var entry = prefCategory.CreateEntry(config.Name, config.Value, null, config.IsInternal) as MelonPreferences_Entry<T>;
|
|
||||||
|
|
||||||
entry.OnValueChangedUntyped += () =>
|
|
||||||
{
|
|
||||||
if ((entry.Value == null && config.Value == null) || config.Value.Equals(entry.Value))
|
|
||||||
return;
|
|
||||||
|
|
||||||
config.Value = entry.Value;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void SetConfigValue<T>(ConfigElement<T> config, T value)
|
|
||||||
{
|
|
||||||
if (prefCategory.GetEntry<T>(config.Name) is MelonPreferences_Entry<T> entry)
|
|
||||||
{
|
|
||||||
entry.Value = value;
|
|
||||||
entry.Save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override T GetConfigValue<T>(ConfigElement<T> config)
|
|
||||||
{
|
|
||||||
if (prefCategory.GetEntry<T>(config.Name) is MelonPreferences_Entry<T> entry)
|
|
||||||
return entry.Value;
|
|
||||||
|
|
||||||
return default;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnAnyConfigChanged()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void SaveConfig()
|
|
||||||
{
|
|
||||||
MelonPreferences.Save();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enum config handlers
|
|
||||||
|
|
||||||
public static KeyCode KeycodeReader(TomlObject value)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
KeyCode kc = (KeyCode)Enum.Parse(typeof(KeyCode), (value as TomlString).Value);
|
|
||||||
|
|
||||||
if (kc == default)
|
|
||||||
throw new Exception();
|
|
||||||
|
|
||||||
return kc;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return KeyCode.F7;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TomlObject KeycodeWriter(KeyCode value)
|
|
||||||
{
|
|
||||||
return MelonPreferences.Mapper.ToToml(value.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static UI.UIManager.VerticalAnchor AnchorReader(TomlObject value)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return (UI.UIManager.VerticalAnchor)Enum.Parse(typeof(UI.UIManager.VerticalAnchor), (value as TomlString).Value);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return UI.UIManager.VerticalAnchor.Top;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TomlObject AnchorWriter(UI.UIManager.VerticalAnchor anchor)
|
|
||||||
{
|
|
||||||
return MelonPreferences.Mapper.ToToml(anchor.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
43
src/Loader/MelonLoader/ExplorerMelonMod.cs
Normal file
43
src/Loader/MelonLoader/ExplorerMelonMod.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#if ML
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using MelonLoader;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.EventSystems;
|
||||||
|
using UnityExplorer;
|
||||||
|
using UnityExplorer.Core;
|
||||||
|
using UnityExplorer.Core.Config;
|
||||||
|
using UnityExplorer.Core.Input;
|
||||||
|
using UnityExplorer.Loader.ML;
|
||||||
|
using HarmonyLib;
|
||||||
|
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.UNIVERSAL)]
|
||||||
|
|
||||||
|
[assembly: MelonInfo(typeof(ExplorerMelonMod), ExplorerCore.NAME, ExplorerCore.VERSION, ExplorerCore.AUTHOR)]
|
||||||
|
[assembly: MelonGame(null, null)]
|
||||||
|
[assembly: MelonColor(ConsoleColor.DarkCyan)]
|
||||||
|
|
||||||
|
namespace UnityExplorer
|
||||||
|
{
|
||||||
|
public class ExplorerMelonMod : MelonMod, IExplorerLoader
|
||||||
|
{
|
||||||
|
public static ExplorerMelonMod Instance;
|
||||||
|
|
||||||
|
public string ExplorerFolder => Path.Combine("Mods", ExplorerCore.NAME);
|
||||||
|
|
||||||
|
public ConfigHandler ConfigHandler => _configHandler;
|
||||||
|
public MelonLoaderConfigHandler _configHandler;
|
||||||
|
|
||||||
|
public Action<object> OnLogMessage => MelonLogger.Msg;
|
||||||
|
public Action<object> OnLogWarning => MelonLogger.Warning;
|
||||||
|
public Action<object> OnLogError => MelonLogger.Error;
|
||||||
|
|
||||||
|
public override void OnApplicationStart()
|
||||||
|
{
|
||||||
|
Instance = this;
|
||||||
|
_configHandler = new MelonLoaderConfigHandler();
|
||||||
|
|
||||||
|
ExplorerCore.Init(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
77
src/Loader/MelonLoader/MelonLoaderConfigHandler.cs
Normal file
77
src/Loader/MelonLoader/MelonLoaderConfigHandler.cs
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
#if ML
|
||||||
|
using MelonLoader;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityExplorer.Core;
|
||||||
|
using UnityExplorer.Core.Config;
|
||||||
|
|
||||||
|
namespace UnityExplorer.Loader.ML
|
||||||
|
{
|
||||||
|
public class MelonLoaderConfigHandler : ConfigHandler
|
||||||
|
{
|
||||||
|
internal const string CTG_NAME = "UnityExplorer";
|
||||||
|
|
||||||
|
internal MelonPreferences_Category prefCategory;
|
||||||
|
|
||||||
|
public override void Init()
|
||||||
|
{
|
||||||
|
prefCategory = MelonPreferences.CreateCategory(CTG_NAME, $"{CTG_NAME} Settings", false, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void LoadConfig()
|
||||||
|
{
|
||||||
|
foreach (var entry in ConfigManager.ConfigElements)
|
||||||
|
{
|
||||||
|
var key = entry.Key;
|
||||||
|
if (prefCategory.GetEntry(key) is MelonPreferences_Entry)
|
||||||
|
{
|
||||||
|
var config = entry.Value;
|
||||||
|
config.BoxedValue = config.GetLoaderConfigValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void RegisterConfigElement<T>(ConfigElement<T> config)
|
||||||
|
{
|
||||||
|
var entry = prefCategory.CreateEntry(config.Name, config.Value, null, config.Description, config.IsInternal, false);
|
||||||
|
|
||||||
|
entry.OnValueChangedUntyped += () =>
|
||||||
|
{
|
||||||
|
if ((entry.Value == null && config.Value == null) || config.Value.Equals(entry.Value))
|
||||||
|
return;
|
||||||
|
|
||||||
|
config.Value = entry.Value;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SetConfigValue<T>(ConfigElement<T> config, T value)
|
||||||
|
{
|
||||||
|
if (prefCategory.GetEntry<T>(config.Name) is MelonPreferences_Entry<T> entry)
|
||||||
|
{
|
||||||
|
entry.Value = value;
|
||||||
|
//entry.Save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override T GetConfigValue<T>(ConfigElement<T> config)
|
||||||
|
{
|
||||||
|
if (prefCategory.GetEntry<T>(config.Name) is MelonPreferences_Entry<T> entry)
|
||||||
|
return entry.Value;
|
||||||
|
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnAnyConfigChanged()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SaveConfig()
|
||||||
|
{
|
||||||
|
MelonPreferences.Save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
@ -21,8 +21,7 @@ namespace UnityExplorer
|
|||||||
/// Call this to initialize UnityExplorer without adding a log listener.
|
/// Call this to initialize UnityExplorer without adding a log listener.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The new (or active, if one exists) instance of ExplorerStandalone.</returns>
|
/// <returns>The new (or active, if one exists) instance of ExplorerStandalone.</returns>
|
||||||
public static ExplorerStandalone CreateInstance()
|
public static ExplorerStandalone CreateInstance() => CreateInstance(null);
|
||||||
=> CreateInstance(null);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Call this to initialize UnityExplorer and add a listener for UnityExplorer's log messages.
|
/// Call this to initialize UnityExplorer and add a listener for UnityExplorer's log messages.
|
||||||
@ -34,6 +33,7 @@ namespace UnityExplorer
|
|||||||
if (Instance != null)
|
if (Instance != null)
|
||||||
return Instance;
|
return Instance;
|
||||||
|
|
||||||
|
if (logListener != null)
|
||||||
OnLog += logListener;
|
OnLog += logListener;
|
||||||
|
|
||||||
var instance = new ExplorerStandalone();
|
var instance = new ExplorerStandalone();
|
||||||
@ -48,9 +48,6 @@ namespace UnityExplorer
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static event Action<string, LogType> OnLog;
|
public static event Action<string, LogType> OnLog;
|
||||||
|
|
||||||
public Harmony HarmonyInstance => s_harmony;
|
|
||||||
public static readonly Harmony s_harmony = new Harmony(ExplorerCore.GUID);
|
|
||||||
|
|
||||||
public ConfigHandler ConfigHandler => _configHandler;
|
public ConfigHandler ConfigHandler => _configHandler;
|
||||||
private StandaloneConfigHandler _configHandler;
|
private StandaloneConfigHandler _configHandler;
|
||||||
|
|
||||||
@ -58,26 +55,12 @@ namespace UnityExplorer
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (s_explorerFolder == null)
|
CheckExplorerFolder();
|
||||||
{
|
|
||||||
s_explorerFolder =
|
|
||||||
Path.Combine(
|
|
||||||
Path.GetDirectoryName(
|
|
||||||
Uri.UnescapeDataString(new Uri(Assembly.GetExecutingAssembly().CodeBase)
|
|
||||||
.AbsolutePath)),
|
|
||||||
"UnityExplorer");
|
|
||||||
|
|
||||||
if (!Directory.Exists(s_explorerFolder))
|
|
||||||
Directory.CreateDirectory(s_explorerFolder);
|
|
||||||
}
|
|
||||||
|
|
||||||
return s_explorerFolder;
|
return s_explorerFolder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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); };
|
||||||
@ -90,45 +73,18 @@ namespace UnityExplorer
|
|||||||
ExplorerCore.Init(this);
|
ExplorerCore.Init(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetupCursorPatches()
|
private void CheckExplorerFolder()
|
||||||
{
|
{
|
||||||
try
|
if (s_explorerFolder == null)
|
||||||
{
|
{
|
||||||
this.HarmonyInstance.PatchAll();
|
s_explorerFolder =
|
||||||
}
|
Path.Combine(
|
||||||
catch (Exception ex)
|
Path.GetDirectoryName(
|
||||||
{
|
Uri.UnescapeDataString(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath)),
|
||||||
ExplorerCore.Log($"Exception setting up Harmony patches:\r\n{ex.ReflectionExToString()}");
|
"UnityExplorer");
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch(typeof(EventSystem), "current", MethodType.Setter)]
|
if (!Directory.Exists(s_explorerFolder))
|
||||||
public class PATCH_EventSystem_current
|
Directory.CreateDirectory(s_explorerFolder);
|
||||||
{
|
|
||||||
[HarmonyPrefix]
|
|
||||||
public static void Prefix_EventSystem_set_current(ref EventSystem value)
|
|
||||||
{
|
|
||||||
CursorUnlocker.Prefix_EventSystem_set_current(ref value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch(typeof(Cursor), "lockState", MethodType.Setter)]
|
|
||||||
public class PATCH_Cursor_lockState
|
|
||||||
{
|
|
||||||
[HarmonyPrefix]
|
|
||||||
public static void Prefix_set_lockState(ref CursorLockMode value)
|
|
||||||
{
|
|
||||||
CursorUnlocker.Prefix_set_lockState(ref value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch(typeof(Cursor), "visible", MethodType.Setter)]
|
|
||||||
public class PATCH_Cursor_visible
|
|
||||||
{
|
|
||||||
[HarmonyPrefix]
|
|
||||||
public static void Prefix_set_visible(ref bool value)
|
|
||||||
{
|
|
||||||
CursorUnlocker.Prefix_set_visible(ref value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,12 +4,13 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
using UnityExplorer.UI;
|
||||||
using UnityExplorer.UI.Models;
|
using UnityExplorer.UI.Models;
|
||||||
using UnityExplorer.UI.Panels;
|
using UnityExplorer.UI.Panels;
|
||||||
using UnityExplorer.UI.Widgets;
|
using UnityExplorer.UI.Widgets;
|
||||||
using UnityExplorer.UI.Widgets.AutoComplete;
|
using UnityExplorer.UI.Widgets.AutoComplete;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.ObjectExplorer
|
namespace UnityExplorer.ObjectExplorer
|
||||||
{
|
{
|
||||||
public class ObjectSearch : UIModel
|
public class ObjectSearch : UIModel
|
||||||
{
|
{
|
||||||
@ -52,8 +53,8 @@ namespace UnityExplorer.UI.ObjectExplorer
|
|||||||
|
|
||||||
if (m_context == SearchContext.Singleton)
|
if (m_context == SearchContext.Singleton)
|
||||||
currentResults = SearchProvider.SingletonSearch(nameInputField.Text);
|
currentResults = SearchProvider.SingletonSearch(nameInputField.Text);
|
||||||
else if (m_context == SearchContext.StaticClass)
|
else if (m_context == SearchContext.Class)
|
||||||
currentResults = SearchProvider.StaticClassSearch(nameInputField.Text);
|
currentResults = SearchProvider.ClassSearch(nameInputField.Text);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string compType = "";
|
string compType = "";
|
||||||
@ -76,7 +77,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);
|
||||||
@ -129,8 +130,11 @@ namespace UnityExplorer.UI.ObjectExplorer
|
|||||||
if (!cachedCellTexts.ContainsKey(index))
|
if (!cachedCellTexts.ContainsKey(index))
|
||||||
{
|
{
|
||||||
string text;
|
string text;
|
||||||
if (m_context == SearchContext.StaticClass)
|
if (m_context == SearchContext.Class)
|
||||||
text = SignatureHighlighter.Parse(currentResults[index] as Type, true);
|
{
|
||||||
|
var type = currentResults[index] as Type;
|
||||||
|
text = $"{SignatureHighlighter.Parse(type, true)} <color=grey><i>({type.Assembly.GetName().Name})</i></color>";
|
||||||
|
}
|
||||||
else
|
else
|
||||||
text = ToStringUtility.ToStringWithType(currentResults[index], currentResults[index]?.GetActualType());
|
text = ToStringUtility.ToStringWithType(currentResults[index], currentResults[index]?.GetActualType());
|
||||||
|
|
||||||
@ -142,7 +146,7 @@ namespace UnityExplorer.UI.ObjectExplorer
|
|||||||
|
|
||||||
private void OnCellClicked(int dataIndex)
|
private void OnCellClicked(int dataIndex)
|
||||||
{
|
{
|
||||||
if (m_context == SearchContext.StaticClass)
|
if (m_context == SearchContext.Class)
|
||||||
InspectorManager.Inspect(currentResults[dataIndex] as Type);
|
InspectorManager.Inspect(currentResults[dataIndex] as Type);
|
||||||
else
|
else
|
||||||
InspectorManager.Inspect(currentResults[dataIndex]);
|
InspectorManager.Inspect(currentResults[dataIndex]);
|
@ -8,11 +8,12 @@ using UnityEngine;
|
|||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.Core;
|
using UnityExplorer.Core;
|
||||||
|
using UnityExplorer.UI;
|
||||||
using UnityExplorer.UI.Models;
|
using UnityExplorer.UI.Models;
|
||||||
using UnityExplorer.UI.Panels;
|
using UnityExplorer.UI.Panels;
|
||||||
using UnityExplorer.UI.Widgets;
|
using UnityExplorer.UI.Widgets;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.ObjectExplorer
|
namespace UnityExplorer.ObjectExplorer
|
||||||
{
|
{
|
||||||
public class SceneExplorer : UIModel
|
public class SceneExplorer : UIModel
|
||||||
{
|
{
|
||||||
@ -113,7 +114,7 @@ namespace UnityExplorer.UI.ObjectExplorer
|
|||||||
refreshRow.SetActive(!scene.IsValid());
|
refreshRow.SetActive(!scene.IsValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SceneHandler_OnLoadedScenesChanged(ReadOnlyCollection<Scene> loadedScenes)
|
private void SceneHandler_OnLoadedScenesChanged(List<Scene> loadedScenes)
|
||||||
{
|
{
|
||||||
PopulateSceneDropdown();
|
PopulateSceneDropdown();
|
||||||
}
|
}
|
||||||
@ -125,6 +126,9 @@ namespace UnityExplorer.UI.ObjectExplorer
|
|||||||
|
|
||||||
foreach (var scene in SceneHandler.LoadedScenes)
|
foreach (var scene in SceneHandler.LoadedScenes)
|
||||||
{
|
{
|
||||||
|
if (sceneToDropdownOption.ContainsKey(scene))
|
||||||
|
continue;
|
||||||
|
|
||||||
string name = scene.name?.Trim();
|
string name = scene.name?.Trim();
|
||||||
|
|
||||||
if (!scene.IsValid())
|
if (!scene.IsValid())
|
@ -6,7 +6,7 @@ using System.Text;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.ObjectExplorer
|
namespace UnityExplorer.ObjectExplorer
|
||||||
{
|
{
|
||||||
public static class SceneHandler
|
public static class SceneHandler
|
||||||
{
|
{
|
||||||
@ -29,14 +29,12 @@ namespace UnityExplorer.UI.ObjectExplorer
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The GameObjects in the currently inspected scene.
|
/// The GameObjects in the currently inspected scene.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static ReadOnlyCollection<GameObject> CurrentRootObjects => new ReadOnlyCollection<GameObject>(rootObjects);
|
public static GameObject[] CurrentRootObjects { get; private set; } = new GameObject[0];
|
||||||
private static GameObject[] rootObjects = new GameObject[0];
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// All currently loaded Scenes.
|
/// All currently loaded Scenes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static ReadOnlyCollection<Scene> LoadedScenes => new ReadOnlyCollection<Scene>(allLoadedScenes);
|
public static List<Scene> LoadedScenes { get; private set; } = new List<Scene>();
|
||||||
private static readonly List<Scene> allLoadedScenes = new List<Scene>();
|
|
||||||
private static HashSet<Scene> previousLoadedScenes;
|
private static HashSet<Scene> previousLoadedScenes;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -59,7 +57,7 @@ namespace UnityExplorer.UI.ObjectExplorer
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invoked whenever the list of currently loaded Scenes changes. The argument contains all loaded scenes after the change.
|
/// Invoked whenever the list of currently loaded Scenes changes. The argument contains all loaded scenes after the change.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static event Action<ReadOnlyCollection<Scene>> OnLoadedScenesChanged;
|
public static event Action<List<Scene>> OnLoadedScenesChanged;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Equivalent to <see cref="SceneManager.sceneCount"/> + 2, to include 'DontDestroyOnLoad' and the 'None' scene.
|
/// Equivalent to <see cref="SceneManager.sceneCount"/> + 2, to include 'DontDestroyOnLoad' and the 'None' scene.
|
||||||
@ -115,7 +113,7 @@ namespace UnityExplorer.UI.ObjectExplorer
|
|||||||
int confirmedCount = 2;
|
int confirmedCount = 2;
|
||||||
bool inspectedExists = SelectedScene == DontDestroyScene || (SelectedScene.HasValue && SelectedScene.Value == default);
|
bool inspectedExists = SelectedScene == DontDestroyScene || (SelectedScene.HasValue && SelectedScene.Value == default);
|
||||||
|
|
||||||
allLoadedScenes.Clear();
|
LoadedScenes.Clear();
|
||||||
|
|
||||||
for (int i = 0; i < SceneManager.sceneCount; i++)
|
for (int i = 0; i < SceneManager.sceneCount; i++)
|
||||||
{
|
{
|
||||||
@ -131,30 +129,26 @@ namespace UnityExplorer.UI.ObjectExplorer
|
|||||||
if (!inspectedExists && scene == SelectedScene)
|
if (!inspectedExists && scene == SelectedScene)
|
||||||
inspectedExists = true;
|
inspectedExists = true;
|
||||||
|
|
||||||
allLoadedScenes.Add(scene);
|
LoadedScenes.Add(scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool anyChange = confirmedCount != allLoadedScenes.Count;
|
bool anyChange = confirmedCount != LoadedScenes.Count;
|
||||||
|
|
||||||
allLoadedScenes.Add(DontDestroyScene);
|
LoadedScenes.Add(DontDestroyScene);
|
||||||
allLoadedScenes.Add(default);
|
LoadedScenes.Add(default);
|
||||||
previousLoadedScenes = new HashSet<Scene>(allLoadedScenes);
|
previousLoadedScenes = new HashSet<Scene>(LoadedScenes);
|
||||||
|
|
||||||
// Default to first scene if none selected or previous selection no longer exists.
|
// Default to first scene if none selected or previous selection no longer exists.
|
||||||
if (!inspectedExists)
|
if (!inspectedExists)
|
||||||
{
|
SelectedScene = LoadedScenes.First();
|
||||||
SelectedScene = allLoadedScenes.First();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Notify on the list changing at all
|
// Notify on the list changing at all
|
||||||
if (anyChange)
|
if (anyChange)
|
||||||
{
|
|
||||||
OnLoadedScenesChanged?.Invoke(LoadedScenes);
|
OnLoadedScenesChanged?.Invoke(LoadedScenes);
|
||||||
}
|
|
||||||
|
|
||||||
// Finally, update the root objects list.
|
// Finally, update the root objects list.
|
||||||
if (SelectedScene != null && ((Scene)SelectedScene).IsValid())
|
if (SelectedScene != null && ((Scene)SelectedScene).IsValid())
|
||||||
rootObjects = RuntimeProvider.Instance.GetRootGameObjects((Scene)SelectedScene);
|
CurrentRootObjects = RuntimeProvider.Instance.GetRootGameObjects((Scene)SelectedScene);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var allObjects = RuntimeProvider.Instance.FindObjectsOfTypeAll(typeof(GameObject));
|
var allObjects = RuntimeProvider.Instance.FindObjectsOfTypeAll(typeof(GameObject));
|
||||||
@ -165,7 +159,7 @@ namespace UnityExplorer.UI.ObjectExplorer
|
|||||||
if (go.transform.parent == null && !go.scene.IsValid())
|
if (go.transform.parent == null && !go.scene.IsValid())
|
||||||
objects.Add(go);
|
objects.Add(go);
|
||||||
}
|
}
|
||||||
rootObjects = objects.ToArray();
|
CurrentRootObjects = objects.ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,14 +8,13 @@ using UnityEngine.SceneManagement;
|
|||||||
using UnityExplorer.Core;
|
using UnityExplorer.Core;
|
||||||
using UnityExplorer.Core.Runtime;
|
using UnityExplorer.Core.Runtime;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.ObjectExplorer
|
namespace UnityExplorer.ObjectExplorer
|
||||||
{
|
{
|
||||||
public enum SearchContext
|
public enum SearchContext
|
||||||
{
|
{
|
||||||
UnityObject,
|
UnityObject,
|
||||||
// GameObject,
|
|
||||||
Singleton,
|
Singleton,
|
||||||
StaticClass
|
Class
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ChildFilter
|
public enum ChildFilter
|
||||||
@ -134,7 +133,7 @@ namespace UnityExplorer.UI.ObjectExplorer
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static List<object> StaticClassSearch(string input)
|
internal static List<object> ClassSearch(string input)
|
||||||
{
|
{
|
||||||
var list = new List<object>();
|
var list = new List<object>();
|
||||||
|
|
||||||
@ -144,11 +143,10 @@ namespace UnityExplorer.UI.ObjectExplorer
|
|||||||
|
|
||||||
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
|
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
|
||||||
{
|
{
|
||||||
foreach (var type in asm.TryGetTypes().Where(it => it.IsSealed && it.IsAbstract))
|
foreach (var type in asm.TryGetTypes())
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(nameFilter) && !type.FullName.ContainsIgnoreCase(nameFilter))
|
if (!string.IsNullOrEmpty(nameFilter) && !type.FullName.ContainsIgnoreCase(nameFilter))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
list.Add(type);
|
list.Add(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
Binary file not shown.
Binary file not shown.
BIN
src/Resources/legacy.5.6.bundle
Normal file
BIN
src/Resources/legacy.5.6.bundle
Normal file
Binary file not shown.
BIN
src/Resources/legacy.bundle
Normal file
BIN
src/Resources/legacy.bundle
Normal file
Binary file not shown.
BIN
src/Resources/modern.bundle
Normal file
BIN
src/Resources/modern.bundle
Normal file
Binary file not shown.
@ -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;
|
||||||
@ -6,7 +7,7 @@ using UnityEngine;
|
|||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.Core.Config;
|
using UnityExplorer.Core.Config;
|
||||||
using UnityExplorer.UI.CSConsole;
|
using UnityExplorer.CSConsole;
|
||||||
using UnityExplorer.UI.Widgets;
|
using UnityExplorer.UI.Widgets;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.Panels
|
namespace UnityExplorer.UI.Panels
|
||||||
@ -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; }
|
||||||
|
|
||||||
@ -33,6 +35,7 @@ namespace UnityExplorer.UI.Panels
|
|||||||
public Action<bool> OnCtrlRToggled;
|
public Action<bool> OnCtrlRToggled;
|
||||||
public Action<bool> OnSuggestionsToggled;
|
public Action<bool> OnSuggestionsToggled;
|
||||||
public Action<bool> OnAutoIndentToggled;
|
public Action<bool> OnAutoIndentToggled;
|
||||||
|
public Action OnPanelResized;
|
||||||
|
|
||||||
private void InvokeOnValueChanged(string value)
|
private void InvokeOnValueChanged(string value)
|
||||||
{
|
{
|
||||||
@ -60,6 +63,11 @@ namespace UnityExplorer.UI.Panels
|
|||||||
|
|
||||||
// UI Construction
|
// UI Construction
|
||||||
|
|
||||||
|
public override void OnFinishResize(RectTransform panel)
|
||||||
|
{
|
||||||
|
OnPanelResized?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
protected internal override void DoSetDefaultPosAndAnchors()
|
protected internal override void DoSetDefaultPosAndAnchors()
|
||||||
{
|
{
|
||||||
Rect.localPosition = Vector2.zero;
|
Rect.localPosition = Vector2.zero;
|
||||||
@ -121,19 +129,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 +196,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ using System.Text;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.Core.Config;
|
using UnityExplorer.Core.Config;
|
||||||
using UnityExplorer.UI.Inspectors;
|
using UnityExplorer.Inspectors;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.Panels
|
namespace UnityExplorer.UI.Panels
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@ using UnityEngine.UI;
|
|||||||
using UnityExplorer.Core;
|
using UnityExplorer.Core;
|
||||||
using UnityExplorer.Core.Config;
|
using UnityExplorer.Core.Config;
|
||||||
using UnityExplorer.UI.Models;
|
using UnityExplorer.UI.Models;
|
||||||
using UnityExplorer.UI.ObjectExplorer;
|
using UnityExplorer.ObjectExplorer;
|
||||||
using UnityExplorer.UI.Widgets;
|
using UnityExplorer.UI.Widgets;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.Panels
|
namespace UnityExplorer.UI.Panels
|
||||||
|
@ -5,8 +5,8 @@ using System.Text;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.Core.Config;
|
using UnityExplorer.Core.Config;
|
||||||
using UnityExplorer.UI.CacheObject;
|
using UnityExplorer.CacheObject;
|
||||||
using UnityExplorer.UI.CacheObject.Views;
|
using UnityExplorer.CacheObject.Views;
|
||||||
using UnityExplorer.UI.Widgets;
|
using UnityExplorer.UI.Widgets;
|
||||||
|
|
||||||
namespace UnityExplorer.UI.Panels
|
namespace UnityExplorer.UI.Panels
|
||||||
|
@ -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
|
||||||
@ -23,6 +23,7 @@ namespace UnityExplorer.UI.Panels
|
|||||||
{
|
{
|
||||||
s_resizeCursorObj.SetActive(false);
|
s_resizeCursorObj.SetActive(false);
|
||||||
wasAnyDragging = false;
|
wasAnyDragging = false;
|
||||||
|
Resizing = false;
|
||||||
|
|
||||||
foreach (var instance in Instances)
|
foreach (var instance in Instances)
|
||||||
{
|
{
|
||||||
|
@ -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();
|
||||||
@ -210,6 +209,10 @@ namespace UnityExplorer.UI.Panels
|
|||||||
{
|
{
|
||||||
ExplorerCore.LogWarning("Invalid or corrupt panel save data! Restoring to default.");
|
ExplorerCore.LogWarning("Invalid or corrupt panel save data! Restoring to default.");
|
||||||
SetTransformDefaults();
|
SetTransformDefaults();
|
||||||
|
UIManager.Initializing = false;
|
||||||
|
DoSaveToConfigElement();
|
||||||
|
ConfigManager.InternalHandler.SaveConfig();
|
||||||
|
UIManager.Initializing = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,7 +339,7 @@ namespace UnityExplorer.UI.Panels
|
|||||||
if (!rect)
|
if (!rect)
|
||||||
throw new ArgumentNullException("rect");
|
throw new ArgumentNullException("rect");
|
||||||
|
|
||||||
return string.Format(ParseUtility.en_US, "{0},{1},{2},{3}", new object[]
|
return string.Format(CultureInfo.InvariantCulture, "{0},{1},{2},{3}", new object[]
|
||||||
{
|
{
|
||||||
rect.anchorMin.x,
|
rect.anchorMin.x,
|
||||||
rect.anchorMin.y,
|
rect.anchorMin.y,
|
||||||
@ -350,16 +353,20 @@ namespace UnityExplorer.UI.Panels
|
|||||||
if (string.IsNullOrEmpty(stringAnchors))
|
if (string.IsNullOrEmpty(stringAnchors))
|
||||||
throw new ArgumentNullException("stringAnchors");
|
throw new ArgumentNullException("stringAnchors");
|
||||||
|
|
||||||
|
if (stringAnchors.Contains(" "))
|
||||||
|
// outdated save data, not worth recovering just reset it.
|
||||||
|
throw new Exception("invalid save data, resetting.");
|
||||||
|
|
||||||
var split = stringAnchors.Split(',');
|
var split = stringAnchors.Split(',');
|
||||||
|
|
||||||
if (split.Length != 4)
|
if (split.Length != 4)
|
||||||
throw new Exception($"stringAnchors split is unexpected length: {split.Length}");
|
throw new Exception($"stringAnchors split is unexpected length: {split.Length}");
|
||||||
|
|
||||||
Vector4 anchors;
|
Vector4 anchors;
|
||||||
anchors.x = float.Parse(split[0], ParseUtility.en_US);
|
anchors.x = float.Parse(split[0], CultureInfo.InvariantCulture);
|
||||||
anchors.y = float.Parse(split[1], ParseUtility.en_US);
|
anchors.y = float.Parse(split[1], CultureInfo.InvariantCulture);
|
||||||
anchors.z = float.Parse(split[2], ParseUtility.en_US);
|
anchors.z = float.Parse(split[2], CultureInfo.InvariantCulture);
|
||||||
anchors.w = float.Parse(split[3], ParseUtility.en_US);
|
anchors.w = float.Parse(split[3], CultureInfo.InvariantCulture);
|
||||||
|
|
||||||
panel.anchorMin = new Vector2(anchors.x, anchors.y);
|
panel.anchorMin = new Vector2(anchors.x, anchors.y);
|
||||||
panel.anchorMax = new Vector2(anchors.z, anchors.w);
|
panel.anchorMax = new Vector2(anchors.z, anchors.w);
|
||||||
@ -370,7 +377,7 @@ namespace UnityExplorer.UI.Panels
|
|||||||
if (!rect)
|
if (!rect)
|
||||||
throw new ArgumentNullException("rect");
|
throw new ArgumentNullException("rect");
|
||||||
|
|
||||||
return string.Format(ParseUtility.en_US, "{0},{1}", new object[]
|
return string.Format(CultureInfo.InvariantCulture, "{0},{1}", new object[]
|
||||||
{
|
{
|
||||||
rect.localPosition.x, rect.localPosition.y
|
rect.localPosition.x, rect.localPosition.y
|
||||||
});
|
});
|
||||||
@ -378,14 +385,21 @@ namespace UnityExplorer.UI.Panels
|
|||||||
|
|
||||||
internal static void SetPositionFromString(this RectTransform rect, string stringPosition)
|
internal static void SetPositionFromString(this RectTransform rect, string stringPosition)
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrEmpty(stringPosition))
|
||||||
|
throw new ArgumentNullException(stringPosition);
|
||||||
|
|
||||||
|
if (stringPosition.Contains(" "))
|
||||||
|
// outdated save data, not worth recovering just reset it.
|
||||||
|
throw new Exception("invalid save data, resetting.");
|
||||||
|
|
||||||
var split = stringPosition.Split(',');
|
var split = stringPosition.Split(',');
|
||||||
|
|
||||||
if (split.Length != 2)
|
if (split.Length != 2)
|
||||||
throw new Exception($"stringPosition split is unexpected length: {split.Length}");
|
throw new Exception($"stringPosition split is unexpected length: {split.Length}");
|
||||||
|
|
||||||
Vector3 vector = rect.localPosition;
|
Vector3 vector = rect.localPosition;
|
||||||
vector.x = float.Parse(split[0], ParseUtility.en_US);
|
vector.x = float.Parse(split[0], CultureInfo.InvariantCulture);
|
||||||
vector.y = float.Parse(split[1], ParseUtility.en_US);
|
vector.y = float.Parse(split[1], CultureInfo.InvariantCulture);
|
||||||
rect.localPosition = vector;
|
rect.localPosition = vector;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,12 +16,6 @@ namespace UnityExplorer.UI
|
|||||||
internal static Vector2 _largeElementSize = new Vector2(100, 30);
|
internal static Vector2 _largeElementSize = new Vector2(100, 30);
|
||||||
internal static Vector2 _smallElementSize = new Vector2(25, 25);
|
internal static Vector2 _smallElementSize = new Vector2(25, 25);
|
||||||
internal static Color _defaultTextColor = Color.white;
|
internal static Color _defaultTextColor = Color.white;
|
||||||
internal static Font _defaultFont;
|
|
||||||
|
|
||||||
public static void Init()
|
|
||||||
{
|
|
||||||
_defaultFont = Resources.GetBuiltinResource<Font>("Arial.ttf");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GameObject CreateUIObject(string name, GameObject parent, Vector2 size = default)
|
public static GameObject CreateUIObject(string name, GameObject parent, Vector2 size = default)
|
||||||
{
|
{
|
||||||
@ -48,7 +42,7 @@ namespace UnityExplorer.UI
|
|||||||
internal static void SetDefaultTextValues(Text text)
|
internal static void SetDefaultTextValues(Text text)
|
||||||
{
|
{
|
||||||
text.color = _defaultTextColor;
|
text.color = _defaultTextColor;
|
||||||
text.font = _defaultFont;
|
text.font = UIManager.DefaultFont;
|
||||||
text.fontSize = 14;
|
text.fontSize = 14;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -409,56 +403,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -729,7 +716,7 @@ namespace UnityExplorer.UI
|
|||||||
|
|
||||||
var sliderContainer = CreateVerticalGroup(mainObj, "SliderContainer",
|
var sliderContainer = CreateVerticalGroup(mainObj, "SliderContainer",
|
||||||
false, false, true, true, 0, default, new Color(0.05f, 0.05f, 0.05f));
|
false, false, true, true, 0, default, new Color(0.05f, 0.05f, 0.05f));
|
||||||
SetLayoutElement(sliderContainer, minWidth: 25, flexibleWidth:0, flexibleHeight: 9999);
|
SetLayoutElement(sliderContainer, minWidth: 25, flexibleWidth: 0, flexibleHeight: 9999);
|
||||||
sliderContainer.AddComponent<Mask>();
|
sliderContainer.AddComponent<Mask>();
|
||||||
|
|
||||||
CreateSliderScrollbar(sliderContainer, out Slider slider);
|
CreateSliderScrollbar(sliderContainer, out Slider slider);
|
||||||
|
@ -8,8 +8,8 @@ using UnityEngine.EventSystems;
|
|||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.Core.Config;
|
using UnityExplorer.Core.Config;
|
||||||
using UnityExplorer.Core.Input;
|
using UnityExplorer.Core.Input;
|
||||||
using UnityExplorer.UI.CSConsole;
|
using UnityExplorer.CSConsole;
|
||||||
using UnityExplorer.UI.Inspectors;
|
using UnityExplorer.Inspectors;
|
||||||
using UnityExplorer.UI.Models;
|
using UnityExplorer.UI.Models;
|
||||||
using UnityExplorer.UI.Panels;
|
using UnityExplorer.UI.Panels;
|
||||||
using UnityExplorer.UI.Widgets;
|
using UnityExplorer.UI.Widgets;
|
||||||
@ -36,7 +36,7 @@ namespace UnityExplorer.UI
|
|||||||
Bottom
|
Bottom
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool Initializing { get; private set; } = true;
|
public static bool Initializing { get; internal set; } = true;
|
||||||
|
|
||||||
private static readonly Dictionary<Panels, UIPanel> UIPanels = new Dictionary<Panels, UIPanel>();
|
private static readonly Dictionary<Panels, UIPanel> UIPanels = new Dictionary<Panels, UIPanel>();
|
||||||
|
|
||||||
@ -52,6 +52,7 @@ namespace UnityExplorer.UI
|
|||||||
internal static GameObject PanelHolder { get; private set; }
|
internal static GameObject PanelHolder { get; private set; }
|
||||||
|
|
||||||
internal static Font ConsoleFont { get; private set; }
|
internal static Font ConsoleFont { get; private set; }
|
||||||
|
internal static Font DefaultFont { get; private set; }
|
||||||
internal static Shader BackupShader { get; private set; }
|
internal static Shader BackupShader { get; private set; }
|
||||||
|
|
||||||
public static RectTransform NavBarRect;
|
public static RectTransform NavBarRect;
|
||||||
@ -92,8 +93,6 @@ namespace UnityExplorer.UI
|
|||||||
{
|
{
|
||||||
LoadBundle();
|
LoadBundle();
|
||||||
|
|
||||||
UIFactory.Init();
|
|
||||||
|
|
||||||
CreateRootCanvas();
|
CreateRootCanvas();
|
||||||
|
|
||||||
// Global UI Pool Holder
|
// Global UI Pool Holder
|
||||||
@ -121,6 +120,12 @@ namespace UnityExplorer.UI
|
|||||||
lastScreenWidth = Screen.width;
|
lastScreenWidth = Screen.width;
|
||||||
lastScreenHeight = Screen.height;
|
lastScreenHeight = Screen.height;
|
||||||
|
|
||||||
|
// Failsafe fix
|
||||||
|
foreach (var dropdown in CanvasRoot.GetComponentsInChildren<Dropdown>(true))
|
||||||
|
dropdown.RefreshShownValue();
|
||||||
|
timeInput.Text = string.Empty;
|
||||||
|
timeInput.Text = Time.timeScale.ToString();
|
||||||
|
|
||||||
Initializing = false;
|
Initializing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,7 +383,7 @@ namespace UnityExplorer.UI
|
|||||||
timeInput = UIFactory.CreateInputField(navbarPanel, "TimeInput", "timeScale");
|
timeInput = UIFactory.CreateInputField(navbarPanel, "TimeInput", "timeScale");
|
||||||
UIFactory.SetLayoutElement(timeInput.Component.gameObject, minHeight: 25, minWidth: 40);
|
UIFactory.SetLayoutElement(timeInput.Component.gameObject, minHeight: 25, minWidth: 40);
|
||||||
timeInput.Text = Time.timeScale.ToString("F2");
|
timeInput.Text = Time.timeScale.ToString("F2");
|
||||||
timeInput.Component.onEndEdit.AddListener(OnTimeInputEndEdit);
|
timeInput.Component.GetOnEndEdit().AddListener(OnTimeInputEndEdit);
|
||||||
|
|
||||||
pauseBtn = UIFactory.CreateButton(navbarPanel, "PauseButton", "||", new Color(0.2f, 0.2f, 0.2f));
|
pauseBtn = UIFactory.CreateButton(navbarPanel, "PauseButton", "||", new Color(0.2f, 0.2f, 0.2f));
|
||||||
UIFactory.SetLayoutElement(pauseBtn.Component.gameObject, minHeight: 25, minWidth: 25);
|
UIFactory.SetLayoutElement(pauseBtn.Component.gameObject, minHeight: 25, minWidth: 25);
|
||||||
@ -404,28 +409,57 @@ namespace UnityExplorer.UI
|
|||||||
closeBtn.OnClick += OnCloseButtonClicked;
|
closeBtn.OnClick += OnCloseButtonClicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region UI AssetBundle
|
// UI AssetBundle
|
||||||
|
|
||||||
private static void LoadBundle()
|
private static void LoadBundle()
|
||||||
{
|
{
|
||||||
AssetBundle bundle = null;
|
AssetBundle bundle;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// Get the Major and Minor of the Unity version
|
||||||
|
var split = Application.unityVersion.Split('.');
|
||||||
|
int major = int.Parse(split[0]);
|
||||||
|
int minor = int.Parse(split[1]);
|
||||||
|
|
||||||
|
// Use appropriate AssetBundle for Unity version
|
||||||
|
// >= 2017
|
||||||
|
if (major >= 2017)
|
||||||
bundle = LoadBundle("modern");
|
bundle = LoadBundle("modern");
|
||||||
if (bundle == null)
|
// 5.6.0 to <2017
|
||||||
|
else if (major == 5 && minor >= 6)
|
||||||
|
bundle = LoadBundle("legacy.5.6");
|
||||||
|
// < 5.6.0
|
||||||
|
else
|
||||||
bundle = LoadBundle("legacy");
|
bundle = LoadBundle("legacy");
|
||||||
}
|
}
|
||||||
catch { }
|
catch
|
||||||
|
{
|
||||||
|
ExplorerCore.LogWarning($"Exception parsing Unity version, falling back to old AssetBundle load method...");
|
||||||
|
bundle = LoadBundle("modern") ?? LoadBundle("legacy.5.6") ?? LoadBundle("legacy");
|
||||||
|
}
|
||||||
|
|
||||||
|
AssetBundle LoadBundle(string id)
|
||||||
|
{
|
||||||
|
ExplorerCore.Log($"Loading {id} bundle for Unity {Application.unityVersion}");
|
||||||
|
|
||||||
|
return AssetBundle.LoadFromMemory(ReadFully(typeof(ExplorerCore)
|
||||||
|
.Assembly
|
||||||
|
.GetManifestResourceStream($"UnityExplorer.Resources.{id}.bundle")));
|
||||||
|
}
|
||||||
|
|
||||||
if (bundle == null)
|
if (bundle == null)
|
||||||
{
|
{
|
||||||
ExplorerCore.LogWarning("Could not load the ExplorerUI Bundle!");
|
ExplorerCore.LogWarning("Could not load the ExplorerUI Bundle!");
|
||||||
ConsoleFont = Resources.GetBuiltinResource<Font>("Arial.ttf");
|
ConsoleFont = Resources.GetBuiltinResource<Font>("Arial.ttf");
|
||||||
|
DefaultFont = ConsoleFont;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BackupShader = bundle.LoadAsset<Shader>("DefaultUI");
|
// Bundle loaded
|
||||||
|
ConsoleFont = bundle.LoadAsset<Font>("CONSOLA");
|
||||||
|
DefaultFont = bundle.LoadAsset<Font>("arial");
|
||||||
|
|
||||||
|
BackupShader = bundle.LoadAsset<Shader>("DefaultUI");
|
||||||
// Fix for games which don't ship with 'UI/Default' shader.
|
// Fix for games which don't ship with 'UI/Default' shader.
|
||||||
if (Graphic.defaultGraphicMaterial.shader?.name != "UI/Default")
|
if (Graphic.defaultGraphicMaterial.shader?.name != "UI/Default")
|
||||||
{
|
{
|
||||||
@ -435,15 +469,6 @@ namespace UnityExplorer.UI
|
|||||||
else
|
else
|
||||||
BackupShader = Graphic.defaultGraphicMaterial.shader;
|
BackupShader = Graphic.defaultGraphicMaterial.shader;
|
||||||
|
|
||||||
ConsoleFont = bundle.LoadAsset<Font>("CONSOLA");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static AssetBundle LoadBundle(string id)
|
|
||||||
{
|
|
||||||
var stream = typeof(ExplorerCore).Assembly
|
|
||||||
.GetManifestResourceStream($"UnityExplorer.Resources.explorerui.{id}.bundle");
|
|
||||||
|
|
||||||
return AssetBundle.LoadFromMemory(ReadFully(stream));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] ReadFully(Stream input)
|
private static byte[] ReadFully(Stream input)
|
||||||
@ -457,7 +482,5 @@ namespace UnityExplorer.UI
|
|||||||
return ms.ToArray();
|
return ms.ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user