mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-02 11:32:29 +08:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
d1fbbfa62d | |||
56a3cef245 | |||
61e7915a55 | |||
88e63c8d6a | |||
048e5980a0 | |||
3b851b6e08 | |||
4c029dad90 | |||
3d61011e59 | |||
5285239bc5 | |||
57d3a3f52e |
14
README.md
14
README.md
@ -90,6 +90,20 @@ If these fixes do not work, please create an issue in this repo and I'll do my b
|
|||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
### Inspector API
|
||||||
|
|
||||||
|
If you want to inspect an object or Type from outside the C# console, use the `InspectorManager` class:
|
||||||
|
|
||||||
|
**To inspect an object:**
|
||||||
|
```csharp
|
||||||
|
UnityExplorer.InspectorManager.Inspect(theObject);
|
||||||
|
```
|
||||||
|
|
||||||
|
**To inspect a Type:**
|
||||||
|
```cs
|
||||||
|
UnityExplorer.InspectorManager.Inspect(typeof(SomeClass));
|
||||||
|
```
|
||||||
|
|
||||||
### Object Explorer
|
### Object Explorer
|
||||||
|
|
||||||
* Use the <b>Scene Explorer</b> tab to traverse the active scenes, as well as the DontDestroyOnLoad and HideAndDontSave objects.
|
* Use the <b>Scene Explorer</b> tab to traverse the active scenes, as well as the DontDestroyOnLoad and HideAndDontSave objects.
|
||||||
|
Binary file not shown.
Binary file not shown.
161
build.ps1
161
build.ps1
@ -1,125 +1,134 @@
|
|||||||
# ----------- MelonLoader IL2CPP (net6) -----------
|
# ----------- MelonLoader IL2CPP (net6) -----------
|
||||||
dotnet build src\UnityExplorer.sln -c Release_ML_Cpp_net6
|
dotnet build src/UnityExplorer.sln -c Release_ML_Cpp_net6
|
||||||
$Path = "Release\UnityExplorer.MelonLoader.IL2CPP.net6preview"
|
$Path = "Release\UnityExplorer.MelonLoader.IL2CPP.net6preview"
|
||||||
# ILRepack
|
# ILRepack
|
||||||
lib/ILRepack.exe /target:library /lib:lib\net6 /lib:lib\unhollowed /lib:$Path /internalize /out:$Path\UnityExplorer.ML.IL2CPP.net6preview.dll $Path\UnityExplorer.ML.IL2CPP.net6preview.dll $Path\mcs.dll
|
lib/ILRepack.exe /target:library /lib:lib/net6 /lib:lib/unhollowed /lib:$Path /internalize /out:$Path/UnityExplorer.ML.IL2CPP.net6preview.dll $Path/UnityExplorer.ML.IL2CPP.net6preview.dll $Path/mcs.dll
|
||||||
# (cleanup and move files)
|
# (cleanup and move files)
|
||||||
Remove-Item $Path\UnityExplorer.ML.IL2CPP.net6preview.deps.json
|
Remove-Item $Path/UnityExplorer.ML.IL2CPP.net6preview.deps.json
|
||||||
Remove-Item $Path\Tomlet.dll
|
Remove-Item $Path/Tomlet.dll
|
||||||
Remove-Item $Path\mcs.dll
|
Remove-Item $Path/mcs.dll
|
||||||
Remove-Item $Path\Iced.dll
|
Remove-Item $Path/Iced.dll
|
||||||
Remove-Item $Path\UnhollowerBaseLib.dll
|
Remove-Item $Path/UnhollowerBaseLib.dll
|
||||||
New-Item -Path "$Path" -Name "Mods" -ItemType "directory" -Force
|
New-Item -Path "$Path" -Name "Mods" -ItemType "directory" -Force
|
||||||
Move-Item -Path $Path\UnityExplorer.ML.IL2CPP.net6preview.dll -Destination $Path\Mods -Force
|
Move-Item -Path $Path/UnityExplorer.ML.IL2CPP.net6preview.dll -Destination $Path/Mods -Force
|
||||||
New-Item -Path "$Path" -Name "UserLibs" -ItemType "directory" -Force
|
New-Item -Path "$Path" -Name "UserLibs" -ItemType "directory" -Force
|
||||||
Move-Item -Path $Path\UniverseLib.IL2CPP.dll -Destination $Path\UserLibs -Force
|
Move-Item -Path $Path/UniverseLib.IL2CPP.dll -Destination $Path/UserLibs -Force
|
||||||
# (create zip archive)
|
# (create zip archive)
|
||||||
Compress-Archive -Path $Path\* -CompressionLevel Fastest -DestinationPath $Path\..\UnityExplorer.MelonLoader.IL2CPP.net6preview.zip -Force
|
Remove-Item $Path/../UnityExplorer.MelonLoader.IL2CPP.net6preview.zip -ErrorAction SilentlyContinue
|
||||||
|
7z a $Path/../UnityExplorer.MelonLoader.IL2CPP.net6preview.zip .\$Path\*
|
||||||
|
|
||||||
# ----------- MelonLoader IL2CPP (net472) -----------
|
# ----------- MelonLoader IL2CPP (net472) -----------
|
||||||
dotnet build src\UnityExplorer.sln -c Release_ML_Cpp_net472
|
dotnet build src/UnityExplorer.sln -c Release_ML_Cpp_net472
|
||||||
$Path = "Release\UnityExplorer.MelonLoader.IL2CPP"
|
$Path = "Release/UnityExplorer.MelonLoader.IL2CPP"
|
||||||
# ILRepack
|
# ILRepack
|
||||||
lib/ILRepack.exe /target:library /lib:lib\net472 /lib:lib\net35 /lib:lib\unhollowed /lib:$Path /internalize /out:$Path\UnityExplorer.ML.IL2CPP.dll $Path\UnityExplorer.ML.IL2CPP.dll $Path\mcs.dll
|
lib/ILRepack.exe /target:library /lib:lib/net472 /lib:lib/net35 /lib:lib/unhollowed /lib:$Path /internalize /out:$Path/UnityExplorer.ML.IL2CPP.dll $Path/UnityExplorer.ML.IL2CPP.dll $Path/mcs.dll
|
||||||
# (cleanup and move files)
|
# (cleanup and move files)
|
||||||
Remove-Item $Path\Tomlet.dll
|
Remove-Item $Path/Tomlet.dll
|
||||||
Remove-Item $Path\mcs.dll
|
Remove-Item $Path/mcs.dll
|
||||||
Remove-Item $Path\Iced.dll
|
Remove-Item $Path/Iced.dll
|
||||||
Remove-Item $Path\UnhollowerBaseLib.dll
|
Remove-Item $Path/UnhollowerBaseLib.dll
|
||||||
New-Item -Path "$Path" -Name "Mods" -ItemType "directory" -Force
|
New-Item -Path "$Path" -Name "Mods" -ItemType "directory" -Force
|
||||||
Move-Item -Path $Path\UnityExplorer.ML.IL2CPP.dll -Destination $Path\Mods -Force
|
Move-Item -Path $Path/UnityExplorer.ML.IL2CPP.dll -Destination $Path/Mods -Force
|
||||||
New-Item -Path "$Path" -Name "UserLibs" -ItemType "directory" -Force
|
New-Item -Path "$Path" -Name "UserLibs" -ItemType "directory" -Force
|
||||||
Move-Item -Path $Path\UniverseLib.IL2CPP.dll -Destination $Path\UserLibs -Force
|
Move-Item -Path $Path/UniverseLib.IL2CPP.dll -Destination $Path/UserLibs -Force
|
||||||
# (create zip archive)
|
# (create zip archive)
|
||||||
Compress-Archive -Path $Path\* -CompressionLevel Fastest -DestinationPath $Path\..\UnityExplorer.MelonLoader.IL2CPP.zip -Force
|
Remove-Item $Path/../UnityExplorer.MelonLoader.IL2CPP.zip -ErrorAction SilentlyContinue
|
||||||
|
7z a $Path/../UnityExplorer.MelonLoader.IL2CPP.zip .\$Path\*
|
||||||
|
|
||||||
# ----------- MelonLoader Mono -----------
|
# ----------- MelonLoader Mono -----------
|
||||||
dotnet build src\UnityExplorer.sln -c Release_ML_Mono
|
dotnet build src/UnityExplorer.sln -c Release_ML_Mono
|
||||||
$Path = "Release\UnityExplorer.MelonLoader.Mono"
|
$Path = "Release/UnityExplorer.MelonLoader.Mono"
|
||||||
# ILRepack
|
# ILRepack
|
||||||
lib/ILRepack.exe /target:library /lib:lib\net35 /lib:$Path /internalize /out:$Path\UnityExplorer.ML.Mono.dll $Path\UnityExplorer.ML.Mono.dll $Path\mcs.dll
|
lib/ILRepack.exe /target:library /lib:lib/net35 /lib:$Path /internalize /out:$Path/UnityExplorer.ML.Mono.dll $Path/UnityExplorer.ML.Mono.dll $Path/mcs.dll
|
||||||
# (cleanup and move files)
|
# (cleanup and move files)
|
||||||
Remove-Item $Path\Tomlet.dll
|
Remove-Item $Path/Tomlet.dll
|
||||||
Remove-Item $Path\mcs.dll
|
Remove-Item $Path/mcs.dll
|
||||||
New-Item -Path "$Path" -Name "Mods" -ItemType "directory" -Force
|
New-Item -Path "$Path" -Name "Mods" -ItemType "directory" -Force
|
||||||
Move-Item -Path $Path\UnityExplorer.ML.Mono.dll -Destination $Path\Mods -Force
|
Move-Item -Path $Path/UnityExplorer.ML.Mono.dll -Destination $Path/Mods -Force
|
||||||
New-Item -Path "$Path" -Name "UserLibs" -ItemType "directory" -Force
|
New-Item -Path "$Path" -Name "UserLibs" -ItemType "directory" -Force
|
||||||
Move-Item -Path $Path\UniverseLib.Mono.dll -Destination $Path\UserLibs -Force
|
Move-Item -Path $Path/UniverseLib.Mono.dll -Destination $Path/UserLibs -Force
|
||||||
# (create zip archive)
|
# (create zip archive)
|
||||||
Compress-Archive -Path $Path\* -CompressionLevel Fastest -DestinationPath $Path\..\UnityExplorer.MelonLoader.Mono.zip -Force
|
Remove-Item $Path/../UnityExplorer.MelonLoader.Mono.zip -ErrorAction SilentlyContinue
|
||||||
|
7z a $Path/../UnityExplorer.MelonLoader.Mono.zip .\$Path\*
|
||||||
|
|
||||||
# ----------- BepInEx IL2CPP -----------
|
# ----------- BepInEx IL2CPP -----------
|
||||||
dotnet build src\UnityExplorer.sln -c Release_BIE_Cpp
|
dotnet build src/UnityExplorer.sln -c Release_BIE_Cpp
|
||||||
$Path = "Release\UnityExplorer.BepInEx.IL2CPP"
|
$Path = "Release/UnityExplorer.BepInEx.IL2CPP"
|
||||||
# ILRepack
|
# ILRepack
|
||||||
lib/ILRepack.exe /target:library /lib:lib\net472 /lib:lib\unhollowed /lib:$Path /internalize /out:$Path\UnityExplorer.BIE.IL2CPP.dll $Path\UnityExplorer.BIE.IL2CPP.dll $Path\mcs.dll $Path\Tomlet.dll
|
lib/ILRepack.exe /target:library /lib:lib/net472 /lib:lib/unhollowed /lib:$Path /internalize /out:$Path/UnityExplorer.BIE.IL2CPP.dll $Path/UnityExplorer.BIE.IL2CPP.dll $Path/mcs.dll $Path/Tomlet.dll
|
||||||
# (cleanup and move files)
|
# (cleanup and move files)
|
||||||
Remove-Item $Path\Tomlet.dll
|
Remove-Item $Path/Tomlet.dll
|
||||||
Remove-Item $Path\mcs.dll
|
Remove-Item $Path/mcs.dll
|
||||||
Remove-Item $Path\Iced.dll
|
Remove-Item $Path/Iced.dll
|
||||||
Remove-Item $Path\UnhollowerBaseLib.dll
|
Remove-Item $Path/UnhollowerBaseLib.dll
|
||||||
New-Item -Path "$Path" -Name "plugins" -ItemType "directory" -Force
|
New-Item -Path "$Path" -Name "plugins" -ItemType "directory" -Force
|
||||||
New-Item -Path "$Path" -Name "plugins\sinai-dev-UnityExplorer" -ItemType "directory" -Force
|
New-Item -Path "$Path" -Name "plugins/sinai-dev-UnityExplorer" -ItemType "directory" -Force
|
||||||
Move-Item -Path $Path\UnityExplorer.BIE.IL2CPP.dll -Destination $Path\plugins\sinai-dev-UnityExplorer -Force
|
Move-Item -Path $Path/UnityExplorer.BIE.IL2CPP.dll -Destination $Path/plugins/sinai-dev-UnityExplorer -Force
|
||||||
Move-Item -Path $Path\UniverseLib.IL2CPP.dll -Destination $Path\plugins\sinai-dev-UnityExplorer -Force
|
Move-Item -Path $Path/UniverseLib.IL2CPP.dll -Destination $Path/plugins/sinai-dev-UnityExplorer -Force
|
||||||
# (create zip archive)
|
# (create zip archive)
|
||||||
Compress-Archive -Path $Path\* -CompressionLevel Fastest -DestinationPath $Path\..\UnityExplorer.BepInEx.IL2CPP.zip -Force
|
Remove-Item $Path/../UnityExplorer.BepInEx.IL2CPP.zip -ErrorAction SilentlyContinue
|
||||||
|
7z a $Path/../UnityExplorer.BepInEx.IL2CPP.zip .\$Path\*
|
||||||
|
|
||||||
# ----------- BepInEx 5 Mono -----------
|
# ----------- BepInEx 5 Mono -----------
|
||||||
dotnet build src\UnityExplorer.sln -c Release_BIE5_Mono
|
dotnet build src/UnityExplorer.sln -c Release_BIE5_Mono
|
||||||
$Path = "Release\UnityExplorer.BepInEx5.Mono"
|
$Path = "Release/UnityExplorer.BepInEx5.Mono"
|
||||||
# ILRepack
|
# ILRepack
|
||||||
lib/ILRepack.exe /target:library /lib:lib\net35 /lib:$Path /internalize /out:$Path\UnityExplorer.BIE5.Mono.dll $Path\UnityExplorer.BIE5.Mono.dll $Path\mcs.dll $Path\Tomlet.dll
|
lib/ILRepack.exe /target:library /lib:lib/net35 /lib:$Path /internalize /out:$Path/UnityExplorer.BIE5.Mono.dll $Path/UnityExplorer.BIE5.Mono.dll $Path/mcs.dll $Path/Tomlet.dll
|
||||||
# (cleanup and move files)
|
# (cleanup and move files)
|
||||||
Remove-Item $Path\Tomlet.dll
|
Remove-Item $Path/Tomlet.dll
|
||||||
Remove-Item $Path\mcs.dll
|
Remove-Item $Path/mcs.dll
|
||||||
New-Item -Path "$Path" -Name "plugins" -ItemType "directory" -Force
|
New-Item -Path "$Path" -Name "plugins" -ItemType "directory" -Force
|
||||||
New-Item -Path "$Path" -Name "plugins\sinai-dev-UnityExplorer" -ItemType "directory" -Force
|
New-Item -Path "$Path" -Name "plugins/sinai-dev-UnityExplorer" -ItemType "directory" -Force
|
||||||
Move-Item -Path $Path\UnityExplorer.BIE5.Mono.dll -Destination $Path\plugins\sinai-dev-UnityExplorer -Force
|
Move-Item -Path $Path/UnityExplorer.BIE5.Mono.dll -Destination $Path/plugins/sinai-dev-UnityExplorer -Force
|
||||||
Move-Item -Path $Path\UniverseLib.Mono.dll -Destination $Path\plugins\sinai-dev-UnityExplorer -Force
|
Move-Item -Path $Path/UniverseLib.Mono.dll -Destination $Path/plugins/sinai-dev-UnityExplorer -Force
|
||||||
# (create zip archive)
|
# (create zip archive)
|
||||||
Compress-Archive -Path $Path\* -CompressionLevel Fastest -DestinationPath $Path\..\UnityExplorer.BepInEx5.Mono.zip -Force
|
Remove-Item $Path/../UnityExplorer.BepInEx5.Mono.zip -ErrorAction SilentlyContinue
|
||||||
|
7z a $Path/../UnityExplorer.BepInEx5.Mono.zip .\$Path\*
|
||||||
|
|
||||||
# ----------- BepInEx 6 Mono -----------
|
# ----------- BepInEx 6 Mono -----------
|
||||||
dotnet build src\UnityExplorer.sln -c Release_BIE6_Mono
|
dotnet build src/UnityExplorer.sln -c Release_BIE6_Mono
|
||||||
$Path = "Release\UnityExplorer.BepInEx6.Mono"
|
$Path = "Release/UnityExplorer.BepInEx6.Mono"
|
||||||
# ILRepack
|
# ILRepack
|
||||||
lib/ILRepack.exe /target:library /lib:lib\net35 /lib:$Path /internalize /out:$Path\UnityExplorer.BIE6.Mono.dll $Path\UnityExplorer.BIE6.Mono.dll $Path\mcs.dll $Path\Tomlet.dll
|
lib/ILRepack.exe /target:library /lib:lib/net35 /lib:$Path /internalize /out:$Path/UnityExplorer.BIE6.Mono.dll $Path/UnityExplorer.BIE6.Mono.dll $Path/mcs.dll $Path/Tomlet.dll
|
||||||
# (cleanup and move files)
|
# (cleanup and move files)
|
||||||
Remove-Item $Path\Tomlet.dll
|
Remove-Item $Path/Tomlet.dll
|
||||||
Remove-Item $Path\mcs.dll
|
Remove-Item $Path/mcs.dll
|
||||||
New-Item -Path "$Path" -Name "plugins" -ItemType "directory" -Force
|
New-Item -Path "$Path" -Name "plugins" -ItemType "directory" -Force
|
||||||
New-Item -Path "$Path" -Name "plugins\sinai-dev-UnityExplorer" -ItemType "directory" -Force
|
New-Item -Path "$Path" -Name "plugins/sinai-dev-UnityExplorer" -ItemType "directory" -Force
|
||||||
Move-Item -Path $Path\UnityExplorer.BIE6.Mono.dll -Destination $Path\plugins\sinai-dev-UnityExplorer -Force
|
Move-Item -Path $Path/UnityExplorer.BIE6.Mono.dll -Destination $Path/plugins/sinai-dev-UnityExplorer -Force
|
||||||
Move-Item -Path $Path\UniverseLib.Mono.dll -Destination $Path\plugins\sinai-dev-UnityExplorer -Force
|
Move-Item -Path $Path/UniverseLib.Mono.dll -Destination $Path/plugins/sinai-dev-UnityExplorer -Force
|
||||||
# (create zip archive)
|
# (create zip archive)
|
||||||
Compress-Archive -Path $Path\* -CompressionLevel Fastest -DestinationPath $Path\..\UnityExplorer.BepInEx6.Mono.zip -Force
|
Remove-Item $Path/../UnityExplorer.BepInEx6.Mono.zip -ErrorAction SilentlyContinue
|
||||||
|
7z a $Path/../UnityExplorer.BepInEx6.Mono.zip .\$Path\*
|
||||||
|
|
||||||
# ----------- Standalone Mono -----------
|
# ----------- Standalone Mono -----------
|
||||||
dotnet build src\UnityExplorer.sln -c Release_STANDALONE_Mono
|
dotnet build src/UnityExplorer.sln -c Release_STANDALONE_Mono
|
||||||
$Path = "Release\UnityExplorer.Standalone.Mono"
|
$Path = "Release/UnityExplorer.Standalone.Mono"
|
||||||
# ILRepack
|
# ILRepack
|
||||||
lib/ILRepack.exe /target:library /lib:lib\net35 /lib:$Path /internalize /out:$Path\UnityExplorer.Standalone.Mono.dll $Path\UnityExplorer.Standalone.Mono.dll $Path\mcs.dll $Path\Tomlet.dll
|
lib/ILRepack.exe /target:library /lib:lib/net35 /lib:$Path /internalize /out:$Path/UnityExplorer.Standalone.Mono.dll $Path/UnityExplorer.Standalone.Mono.dll $Path/mcs.dll $Path/Tomlet.dll
|
||||||
# (cleanup and move files)
|
# (cleanup and move files)
|
||||||
Remove-Item $Path\Tomlet.dll
|
Remove-Item $Path/Tomlet.dll
|
||||||
Remove-Item $Path\mcs.dll
|
Remove-Item $Path/mcs.dll
|
||||||
Compress-Archive -Path $Path\* -CompressionLevel Fastest -DestinationPath $Path\..\UnityExplorer.Standalone.Mono.zip -Force
|
Remove-Item $Path/../UnityExplorer.Standalone.Mono.zip -ErrorAction SilentlyContinue
|
||||||
|
7z a $Path/../UnityExplorer.Standalone.Mono.zip .\$Path\*
|
||||||
|
|
||||||
# ----------- Standalone IL2CPP -----------
|
# ----------- Standalone IL2CPP -----------
|
||||||
dotnet build src\UnityExplorer.sln -c Release_STANDALONE_Cpp
|
dotnet build src/UnityExplorer.sln -c Release_STANDALONE_Cpp
|
||||||
$Path = "Release\UnityExplorer.Standalone.IL2CPP"
|
$Path = "Release/UnityExplorer.Standalone.IL2CPP"
|
||||||
# ILRepack
|
# ILRepack
|
||||||
lib/ILRepack.exe /target:library /lib:lib\net472 /lib:lib\unhollowed /lib:$Path /internalize /out:$Path\UnityExplorer.Standalone.IL2CPP.dll $Path\UnityExplorer.Standalone.IL2CPP.dll $Path\mcs.dll $Path\Tomlet.dll
|
lib/ILRepack.exe /target:library /lib:lib/net472 /lib:lib/unhollowed /lib:$Path /internalize /out:$Path/UnityExplorer.Standalone.IL2CPP.dll $Path/UnityExplorer.Standalone.IL2CPP.dll $Path/mcs.dll $Path/Tomlet.dll
|
||||||
# (cleanup and move files)
|
# (cleanup and move files)
|
||||||
Remove-Item $Path\Tomlet.dll
|
Remove-Item $Path/Tomlet.dll
|
||||||
Remove-Item $Path\mcs.dll
|
Remove-Item $Path/mcs.dll
|
||||||
Remove-Item $Path\Iced.dll
|
Remove-Item $Path/Iced.dll
|
||||||
Remove-Item $Path\UnhollowerBaseLib.dll
|
Remove-Item $Path/UnhollowerBaseLib.dll
|
||||||
Compress-Archive -Path $Path\* -CompressionLevel Fastest -DestinationPath $Path\..\UnityExplorer.Standalone.IL2CPP.zip -Force
|
Remove-Item $Path/../UnityExplorer.Standalone.IL2CPP.zip -ErrorAction SilentlyContinue
|
||||||
|
7z a $Path/../UnityExplorer.Standalone.IL2CPP.zip .\$Path\*
|
||||||
|
|
||||||
# ----------- Editor (mono) -----------
|
# ----------- Editor (mono) -----------
|
||||||
$Path1 = "Release\UnityExplorer.Standalone.Mono"
|
$Path1 = "Release/UnityExplorer.Standalone.Mono"
|
||||||
$Path2 = "UnityEditorPackage\Runtime"
|
$Path2 = "UnityEditorPackage/Runtime"
|
||||||
Copy-Item $Path1\UnityExplorer.STANDALONE.Mono.dll -Destination $Path2
|
Copy-Item $Path1/UnityExplorer.STANDALONE.Mono.dll -Destination $Path2
|
||||||
Copy-Item $Path1\UniverseLib.Mono.dll -Destination $Path2
|
Copy-Item $Path1/UniverseLib.Mono.dll -Destination $Path2
|
||||||
Compress-Archive -Path UnityEditorPackage\* -CompressionLevel Fastest -DestinationPath Release\UnityExplorer.Editor.zip -Force
|
Remove-Item Release/UnityExplorer.Editor.zip -ErrorAction SilentlyContinue
|
||||||
|
7z a Release/UnityExplorer.Editor.zip .\UnityEditorPackage\*
|
@ -56,6 +56,7 @@ namespace UnityExplorer.CSConsole
|
|||||||
"System.Text",
|
"System.Text",
|
||||||
"System.Collections",
|
"System.Collections",
|
||||||
"System.Collections.Generic",
|
"System.Collections.Generic",
|
||||||
|
"System.Reflection",
|
||||||
"UnityEngine",
|
"UnityEngine",
|
||||||
"UniverseLib",
|
"UniverseLib",
|
||||||
#if CPP
|
#if CPP
|
||||||
|
@ -3,6 +3,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using UnityExplorer.Config;
|
||||||
|
|
||||||
// Thanks to ManlyMarco for this
|
// Thanks to ManlyMarco for this
|
||||||
|
|
||||||
@ -10,6 +11,9 @@ namespace UnityExplorer.CSConsole
|
|||||||
{
|
{
|
||||||
public class ScriptEvaluator : Evaluator, IDisposable
|
public class ScriptEvaluator : Evaluator, IDisposable
|
||||||
{
|
{
|
||||||
|
internal TextWriter _textWriter;
|
||||||
|
internal static StreamReportPrinter _reportPrinter;
|
||||||
|
|
||||||
private static readonly HashSet<string> StdLib = new(StringComparer.InvariantCultureIgnoreCase)
|
private static readonly HashSet<string> StdLib = new(StringComparer.InvariantCultureIgnoreCase)
|
||||||
{
|
{
|
||||||
"mscorlib",
|
"mscorlib",
|
||||||
@ -18,9 +22,6 @@ namespace UnityExplorer.CSConsole
|
|||||||
"System.Xml"
|
"System.Xml"
|
||||||
};
|
};
|
||||||
|
|
||||||
internal TextWriter _textWriter;
|
|
||||||
internal static StreamReportPrinter _reportPrinter;
|
|
||||||
|
|
||||||
public ScriptEvaluator(TextWriter tw) : base(BuildContext(tw))
|
public ScriptEvaluator(TextWriter tw) : base(BuildContext(tw))
|
||||||
{
|
{
|
||||||
_textWriter = tw;
|
_textWriter = tw;
|
||||||
@ -48,8 +49,19 @@ namespace UnityExplorer.CSConsole
|
|||||||
private void Reference(Assembly asm)
|
private void Reference(Assembly asm)
|
||||||
{
|
{
|
||||||
string name = asm.GetName().Name;
|
string name = asm.GetName().Name;
|
||||||
if (name == "completions")
|
|
||||||
|
if (name == "completions") // ignore assemblies generated by mcs' autocomplete.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
foreach (string blacklisted in ConfigManager.CSConsole_Assembly_Blacklist.Value.Split(';'))
|
||||||
|
{
|
||||||
|
string bl = blacklisted;
|
||||||
|
if (bl.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
|
||||||
|
bl = blacklisted.Substring(0, bl.Length - 4);
|
||||||
|
if (string.Equals(bl, name, StringComparison.OrdinalIgnoreCase))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ReferenceAssembly(asm);
|
ReferenceAssembly(asm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,10 +25,11 @@ namespace UnityExplorer.Config
|
|||||||
public static ConfigElement<string> Default_Output_Path;
|
public static ConfigElement<string> Default_Output_Path;
|
||||||
public static ConfigElement<string> DnSpy_Path;
|
public static ConfigElement<string> DnSpy_Path;
|
||||||
public static ConfigElement<bool> Log_Unity_Debug;
|
public static ConfigElement<bool> Log_Unity_Debug;
|
||||||
public static ConfigElement<string> Reflection_Signature_Blacklist;
|
|
||||||
public static ConfigElement<UIManager.VerticalAnchor> Main_Navbar_Anchor;
|
public static ConfigElement<UIManager.VerticalAnchor> Main_Navbar_Anchor;
|
||||||
public static ConfigElement<KeyCode> World_MouseInspect_Keybind;
|
public static ConfigElement<KeyCode> World_MouseInspect_Keybind;
|
||||||
public static ConfigElement<KeyCode> UI_MouseInspect_Keybind;
|
public static ConfigElement<KeyCode> UI_MouseInspect_Keybind;
|
||||||
|
public static ConfigElement<string> CSConsole_Assembly_Blacklist;
|
||||||
|
public static ConfigElement<string> Reflection_Signature_Blacklist;
|
||||||
|
|
||||||
// internal configs
|
// internal configs
|
||||||
internal static InternalConfigHandler InternalHandler { get; private set; }
|
internal static InternalConfigHandler InternalHandler { get; private set; }
|
||||||
@ -57,8 +58,6 @@ namespace UnityExplorer.Config
|
|||||||
#if STANDALONE
|
#if STANDALONE
|
||||||
Loader.Standalone.ExplorerEditorBehaviour.Instance?.LoadConfigs();
|
Loader.Standalone.ExplorerEditorBehaviour.Instance?.LoadConfigs();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//InitConsoleCallback();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void RegisterConfigElement<T>(ConfigElement<T> configElement)
|
internal static void RegisterConfigElement<T>(ConfigElement<T> configElement)
|
||||||
@ -77,50 +76,50 @@ namespace UnityExplorer.Config
|
|||||||
|
|
||||||
private static void CreateConfigElements()
|
private static void CreateConfigElements()
|
||||||
{
|
{
|
||||||
Master_Toggle = new ConfigElement<KeyCode>("UnityExplorer Toggle",
|
Master_Toggle = new("UnityExplorer Toggle",
|
||||||
"The key to enable or disable UnityExplorer's menu and features.",
|
"The key to enable or disable UnityExplorer's menu and features.",
|
||||||
KeyCode.F7);
|
KeyCode.F7);
|
||||||
|
|
||||||
Hide_On_Startup = new ConfigElement<bool>("Hide On Startup",
|
Hide_On_Startup = new("Hide On Startup",
|
||||||
"Should UnityExplorer be hidden on startup?",
|
"Should UnityExplorer be hidden on startup?",
|
||||||
false);
|
false);
|
||||||
|
|
||||||
Startup_Delay_Time = new ConfigElement<float>("Startup Delay Time",
|
Startup_Delay_Time = new("Startup Delay Time",
|
||||||
"The delay on startup before the UI is created.",
|
"The delay on startup before the UI is created.",
|
||||||
1f);
|
1f);
|
||||||
|
|
||||||
Target_Display = new ConfigElement<int>("Target Display",
|
Target_Display = new("Target Display",
|
||||||
"The monitor index for UnityExplorer to use, if you have multiple. 0 is the default display, 1 is secondary, etc. " +
|
"The monitor index for UnityExplorer to use, if you have multiple. 0 is the default display, 1 is secondary, etc. " +
|
||||||
"Restart recommended when changing this setting. Make sure your extra monitors are the same resolution as your primary monitor.",
|
"Restart recommended when changing this setting. Make sure your extra monitors are the same resolution as your primary monitor.",
|
||||||
0);
|
0);
|
||||||
|
|
||||||
Force_Unlock_Mouse = new ConfigElement<bool>("Force Unlock Mouse",
|
Force_Unlock_Mouse = new("Force Unlock Mouse",
|
||||||
"Force the Cursor to be unlocked (visible) when the UnityExplorer menu is open.",
|
"Force the Cursor to be unlocked (visible) when the UnityExplorer menu is open.",
|
||||||
true);
|
true);
|
||||||
Force_Unlock_Mouse.OnValueChanged += (bool value) => UniverseLib.Config.ConfigManager.Force_Unlock_Mouse = value;
|
Force_Unlock_Mouse.OnValueChanged += (bool value) => UniverseLib.Config.ConfigManager.Force_Unlock_Mouse = value;
|
||||||
|
|
||||||
Force_Unlock_Toggle = new ConfigElement<KeyCode>("Force Unlock Toggle Key",
|
Force_Unlock_Toggle = new("Force Unlock Toggle Key",
|
||||||
"The keybind to toggle the 'Force Unlock Mouse' setting. Only usable when UnityExplorer is open.",
|
"The keybind to toggle the 'Force Unlock Mouse' setting. Only usable when UnityExplorer is open.",
|
||||||
KeyCode.None);
|
KeyCode.None);
|
||||||
|
|
||||||
Disable_EventSystem_Override = new ConfigElement<bool>("Disable EventSystem override",
|
Disable_EventSystem_Override = new("Disable EventSystem override",
|
||||||
"If enabled, UnityExplorer will not override the EventSystem from the game.\n<b>May require restart to take effect.</b>",
|
"If enabled, UnityExplorer will not override the EventSystem from the game.\n<b>May require restart to take effect.</b>",
|
||||||
false);
|
false);
|
||||||
Disable_EventSystem_Override.OnValueChanged += (bool value) => UniverseLib.Config.ConfigManager.Disable_EventSystem_Override = value;
|
Disable_EventSystem_Override.OnValueChanged += (bool value) => UniverseLib.Config.ConfigManager.Disable_EventSystem_Override = value;
|
||||||
|
|
||||||
Default_Output_Path = new ConfigElement<string>("Default Output Path",
|
Default_Output_Path = new("Default Output Path",
|
||||||
"The default output path when exporting things from UnityExplorer.",
|
"The default output path when exporting things from UnityExplorer.",
|
||||||
Path.Combine(ExplorerCore.ExplorerFolder, "Output"));
|
Path.Combine(ExplorerCore.ExplorerFolder, "Output"));
|
||||||
|
|
||||||
DnSpy_Path = new ConfigElement<string>("dnSpy Path",
|
DnSpy_Path = new("dnSpy Path",
|
||||||
"The full path to dnSpy.exe (64-bit).",
|
"The full path to dnSpy.exe (64-bit).",
|
||||||
@"C:/Program Files/dnspy/dnSpy.exe");
|
@"C:/Program Files/dnspy/dnSpy.exe");
|
||||||
|
|
||||||
Main_Navbar_Anchor = new ConfigElement<UIManager.VerticalAnchor>("Main Navbar Anchor",
|
Main_Navbar_Anchor = new("Main Navbar Anchor",
|
||||||
"The vertical anchor of the main UnityExplorer Navbar, in case you want to move it.",
|
"The vertical anchor of the main UnityExplorer Navbar, in case you want to move it.",
|
||||||
UIManager.VerticalAnchor.Top);
|
UIManager.VerticalAnchor.Top);
|
||||||
|
|
||||||
Log_Unity_Debug = new ConfigElement<bool>("Log Unity Debug",
|
Log_Unity_Debug = new("Log Unity Debug",
|
||||||
"Should UnityEngine.Debug.Log messages be printed to UnityExplorer's log?",
|
"Should UnityEngine.Debug.Log messages be printed to UnityExplorer's log?",
|
||||||
false);
|
false);
|
||||||
|
|
||||||
@ -132,7 +131,13 @@ namespace UnityExplorer.Config
|
|||||||
"Optional keybind to begin a UI-mode Mouse Inspect.",
|
"Optional keybind to begin a UI-mode Mouse Inspect.",
|
||||||
KeyCode.None);
|
KeyCode.None);
|
||||||
|
|
||||||
Reflection_Signature_Blacklist = new ConfigElement<string>("Member Signature Blacklist",
|
CSConsole_Assembly_Blacklist = new("CSharp Console Assembly Blacklist",
|
||||||
|
"Use this to blacklist Assembly names from being referenced by the C# Console. Requires a Reset of the C# Console.\n" +
|
||||||
|
"Separate each Assembly with a semicolon ';'." +
|
||||||
|
"For example, to blacklist Assembly-CSharp, you would add 'Assembly-CSharp;'",
|
||||||
|
"");
|
||||||
|
|
||||||
|
Reflection_Signature_Blacklist = new("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 'UnityEngine.Camera.main;'",
|
"For example, to blacklist Camera.main, you would add 'UnityEngine.Camera.main;'",
|
||||||
|
@ -14,7 +14,7 @@ namespace UnityExplorer
|
|||||||
public static class ExplorerCore
|
public static class ExplorerCore
|
||||||
{
|
{
|
||||||
public const string NAME = "UnityExplorer";
|
public const string NAME = "UnityExplorer";
|
||||||
public const string VERSION = "4.8.0";
|
public const string VERSION = "4.8.1";
|
||||||
public const string AUTHOR = "Sinai";
|
public const string AUTHOR = "Sinai";
|
||||||
public const string GUID = "com.sinai.unityexplorer";
|
public const string GUID = "com.sinai.unityexplorer";
|
||||||
|
|
||||||
|
@ -236,6 +236,8 @@ namespace UnityExplorer.Hooks
|
|||||||
CurrentEditedHook = null;
|
CurrentEditedHook = null;
|
||||||
HookManagerPanel.Instance.SetPage(HookManagerPanel.Pages.ClassMethodSelector);
|
HookManagerPanel.Instance.SetPage(HookManagerPanel.Pages.ClassMethodSelector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HookList.HooksScrollPool.Refresh(true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// UI Construction
|
// UI Construction
|
||||||
|
@ -113,17 +113,11 @@ namespace UnityExplorer.Inspectors
|
|||||||
|
|
||||||
public bool TryUpdate()
|
public bool TryUpdate()
|
||||||
{
|
{
|
||||||
if (ConfigManager.World_MouseInspect_Keybind.Value != KeyCode.None)
|
if (InputManager.GetKeyDown(ConfigManager.World_MouseInspect_Keybind.Value))
|
||||||
{
|
Instance.StartInspect(MouseInspectMode.World);
|
||||||
if (InputManager.GetKeyDown(ConfigManager.World_MouseInspect_Keybind.Value))
|
|
||||||
Instance.StartInspect(MouseInspectMode.World);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ConfigManager.World_MouseInspect_Keybind.Value != KeyCode.None)
|
if (InputManager.GetKeyDown(ConfigManager.UI_MouseInspect_Keybind.Value))
|
||||||
{
|
Instance.StartInspect(MouseInspectMode.UI);
|
||||||
if (InputManager.GetKeyDown(ConfigManager.World_MouseInspect_Keybind.Value))
|
|
||||||
Instance.StartInspect(MouseInspectMode.World);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Inspecting)
|
if (Inspecting)
|
||||||
UpdateInspect();
|
UpdateInspect();
|
||||||
|
@ -71,6 +71,17 @@ namespace UnityExplorer.UI.Panels
|
|||||||
|
|
||||||
// Save Data
|
// Save Data
|
||||||
|
|
||||||
|
bool setDefault = false;
|
||||||
|
|
||||||
|
public override void SetDefaultSizeAndPosition()
|
||||||
|
{
|
||||||
|
if (setDefault)
|
||||||
|
return;
|
||||||
|
setDefault = true;
|
||||||
|
|
||||||
|
base.SetDefaultSizeAndPosition();
|
||||||
|
}
|
||||||
|
|
||||||
public bool ApplyingSaveData { get; set; }
|
public bool ApplyingSaveData { get; set; }
|
||||||
|
|
||||||
public void SaveInternalData()
|
public void SaveInternalData()
|
||||||
|
@ -5,6 +5,7 @@ using UnityExplorer.Config;
|
|||||||
using UnityExplorer.CSConsole;
|
using UnityExplorer.CSConsole;
|
||||||
using UnityExplorer.Inspectors;
|
using UnityExplorer.Inspectors;
|
||||||
using UnityExplorer.UI.Panels;
|
using UnityExplorer.UI.Panels;
|
||||||
|
using UnityExplorer.UI.Widgets;
|
||||||
using UnityExplorer.UI.Widgets.AutoComplete;
|
using UnityExplorer.UI.Widgets.AutoComplete;
|
||||||
using UniverseLib;
|
using UniverseLib;
|
||||||
using UniverseLib.Input;
|
using UniverseLib.Input;
|
||||||
@ -54,10 +55,7 @@ namespace UnityExplorer.UI
|
|||||||
private static readonly Vector2 NAVBAR_DIMENSIONS = new(1020f, 35f);
|
private static readonly Vector2 NAVBAR_DIMENSIONS = new(1020f, 35f);
|
||||||
|
|
||||||
private static ButtonRef closeBtn;
|
private static ButtonRef closeBtn;
|
||||||
private static ButtonRef pauseBtn;
|
private static TimeScaleWidget timeScaleWidget;
|
||||||
private static InputFieldRef timeInput;
|
|
||||||
private static bool pauseButtonPausing;
|
|
||||||
private static float lastTimeScale;
|
|
||||||
|
|
||||||
private static int lastScreenWidth;
|
private static int lastScreenWidth;
|
||||||
private static int lastScreenHeight;
|
private static int lastScreenHeight;
|
||||||
@ -141,20 +139,7 @@ namespace UnityExplorer.UI
|
|||||||
UniverseLib.Config.ConfigManager.Force_Unlock_Mouse = !UniverseLib.Config.ConfigManager.Force_Unlock_Mouse;
|
UniverseLib.Config.ConfigManager.Force_Unlock_Mouse = !UniverseLib.Config.ConfigManager.Force_Unlock_Mouse;
|
||||||
|
|
||||||
// update the timescale value
|
// update the timescale value
|
||||||
if (!timeInput.Component.isFocused && lastTimeScale != Time.timeScale)
|
timeScaleWidget.Update();
|
||||||
{
|
|
||||||
if (pauseButtonPausing && Time.timeScale != 0.0f)
|
|
||||||
{
|
|
||||||
pauseButtonPausing = false;
|
|
||||||
OnPauseButtonToggled();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pauseButtonPausing)
|
|
||||||
{
|
|
||||||
timeInput.Text = Time.timeScale.ToString("F2");
|
|
||||||
lastTimeScale = Time.timeScale;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// check screen dimension change
|
// check screen dimension change
|
||||||
Display display = DisplayManager.ActiveDisplay;
|
Display display = DisplayManager.ActiveDisplay;
|
||||||
@ -232,41 +217,7 @@ namespace UnityExplorer.UI
|
|||||||
closeBtn.ButtonText.text = val.ToString();
|
closeBtn.ButtonText.text = val.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Time controls
|
|
||||||
|
|
||||||
private static void OnTimeInputEndEdit(string val)
|
|
||||||
{
|
|
||||||
if (pauseButtonPausing)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (float.TryParse(val, out float f))
|
|
||||||
{
|
|
||||||
Time.timeScale = f;
|
|
||||||
lastTimeScale = f;
|
|
||||||
}
|
|
||||||
|
|
||||||
timeInput.Text = Time.timeScale.ToString("F2");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void OnPauseButtonClicked()
|
|
||||||
{
|
|
||||||
pauseButtonPausing = !pauseButtonPausing;
|
|
||||||
|
|
||||||
Time.timeScale = pauseButtonPausing ? 0f : lastTimeScale;
|
|
||||||
|
|
||||||
OnPauseButtonToggled();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void OnPauseButtonToggled()
|
|
||||||
{
|
|
||||||
timeInput.Component.text = Time.timeScale.ToString("F2");
|
|
||||||
timeInput.Component.readOnly = pauseButtonPausing;
|
|
||||||
timeInput.Component.textComponent.color = pauseButtonPausing ? Color.grey : Color.white;
|
|
||||||
|
|
||||||
Color color = pauseButtonPausing ? new Color(0.3f, 0.3f, 0.2f) : new Color(0.2f, 0.2f, 0.2f);
|
|
||||||
RuntimeHelper.SetColorBlock(pauseBtn.Component, color, color * 1.2f, color * 0.7f);
|
|
||||||
pauseBtn.ButtonText.text = pauseButtonPausing ? "►" : "||";
|
|
||||||
}
|
|
||||||
|
|
||||||
// UI Construction
|
// UI Construction
|
||||||
|
|
||||||
@ -298,26 +249,17 @@ namespace UnityExplorer.UI
|
|||||||
UIFactory.SetLayoutElement(NavbarTabButtonHolder, minHeight: 25, flexibleHeight: 999, flexibleWidth: 999);
|
UIFactory.SetLayoutElement(NavbarTabButtonHolder, minHeight: 25, flexibleHeight: 999, flexibleWidth: 999);
|
||||||
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(NavbarTabButtonHolder, false, true, true, true, 4, 2, 2, 2, 2);
|
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(NavbarTabButtonHolder, false, true, true, true, 4, 2, 2, 2, 2);
|
||||||
|
|
||||||
// Time controls
|
// Time scale widget
|
||||||
|
timeScaleWidget = new(navbarPanel);
|
||||||
|
|
||||||
Text timeLabel = UIFactory.CreateLabel(navbarPanel, "TimeLabel", "Time:", TextAnchor.MiddleRight, Color.grey);
|
//spacer
|
||||||
UIFactory.SetLayoutElement(timeLabel.gameObject, minHeight: 25, minWidth: 50);
|
GameObject spacer = UIFactory.CreateUIObject("Spacer", navbarPanel);
|
||||||
|
UIFactory.SetLayoutElement(spacer, minWidth: 15);
|
||||||
timeInput = UIFactory.CreateInputField(navbarPanel, "TimeInput", "timeScale");
|
|
||||||
UIFactory.SetLayoutElement(timeInput.Component.gameObject, minHeight: 25, minWidth: 40);
|
|
||||||
timeInput.Component.GetOnEndEdit().AddListener(OnTimeInputEndEdit);
|
|
||||||
|
|
||||||
timeInput.Text = string.Empty;
|
|
||||||
timeInput.Text = Time.timeScale.ToString();
|
|
||||||
|
|
||||||
pauseBtn = UIFactory.CreateButton(navbarPanel, "PauseButton", "||", new Color(0.2f, 0.2f, 0.2f));
|
|
||||||
UIFactory.SetLayoutElement(pauseBtn.Component.gameObject, minHeight: 25, minWidth: 25);
|
|
||||||
pauseBtn.OnClick += OnPauseButtonClicked;
|
|
||||||
|
|
||||||
// Hide menu button
|
// Hide menu button
|
||||||
|
|
||||||
closeBtn = UIFactory.CreateButton(navbarPanel, "CloseButton", ConfigManager.Master_Toggle.Value.ToString());
|
closeBtn = UIFactory.CreateButton(navbarPanel, "CloseButton", ConfigManager.Master_Toggle.Value.ToString());
|
||||||
UIFactory.SetLayoutElement(closeBtn.Component.gameObject, minHeight: 25, minWidth: 80, flexibleWidth: 0);
|
UIFactory.SetLayoutElement(closeBtn.Component.gameObject, minHeight: 25, minWidth: 60, flexibleWidth: 0);
|
||||||
RuntimeHelper.SetColorBlock(closeBtn.Component, new Color(0.63f, 0.32f, 0.31f),
|
RuntimeHelper.SetColorBlock(closeBtn.Component, new Color(0.63f, 0.32f, 0.31f),
|
||||||
new Color(0.81f, 0.25f, 0.2f), new Color(0.6f, 0.18f, 0.16f));
|
new Color(0.81f, 0.25f, 0.2f), new Color(0.6f, 0.18f, 0.16f));
|
||||||
|
|
||||||
|
116
src/UI/Widgets/TimeScaleWidget.cs
Normal file
116
src/UI/Widgets/TimeScaleWidget.cs
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
using HarmonyLib;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
using UniverseLib;
|
||||||
|
using UniverseLib.UI;
|
||||||
|
using UniverseLib.UI.Models;
|
||||||
|
using UniverseLib.Utility;
|
||||||
|
|
||||||
|
namespace UnityExplorer.UI.Widgets
|
||||||
|
{
|
||||||
|
internal class TimeScaleWidget
|
||||||
|
{
|
||||||
|
public TimeScaleWidget(GameObject parent)
|
||||||
|
{
|
||||||
|
Instance = this;
|
||||||
|
|
||||||
|
ConstructUI(parent);
|
||||||
|
|
||||||
|
InitPatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
static TimeScaleWidget Instance;
|
||||||
|
|
||||||
|
ButtonRef lockBtn;
|
||||||
|
bool locked;
|
||||||
|
InputFieldRef timeInput;
|
||||||
|
float desiredTime;
|
||||||
|
bool settingTimeScale;
|
||||||
|
|
||||||
|
public void Update()
|
||||||
|
{
|
||||||
|
// Fallback in case Time.timeScale patch failed for whatever reason
|
||||||
|
if (locked)
|
||||||
|
SetTimeScale(desiredTime);
|
||||||
|
|
||||||
|
if (!timeInput.Component.isFocused)
|
||||||
|
timeInput.Text = Time.timeScale.ToString("F2");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetTimeScale(float time)
|
||||||
|
{
|
||||||
|
settingTimeScale = true;
|
||||||
|
Time.timeScale = time;
|
||||||
|
settingTimeScale = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// UI event listeners
|
||||||
|
|
||||||
|
void OnTimeInputEndEdit(string val)
|
||||||
|
{
|
||||||
|
if (float.TryParse(val, out float f))
|
||||||
|
{
|
||||||
|
SetTimeScale(f);
|
||||||
|
desiredTime = f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnPauseButtonClicked()
|
||||||
|
{
|
||||||
|
OnTimeInputEndEdit(timeInput.Text);
|
||||||
|
|
||||||
|
locked = !locked;
|
||||||
|
|
||||||
|
Color color = locked ? new Color(0.3f, 0.3f, 0.2f) : new Color(0.2f, 0.2f, 0.2f);
|
||||||
|
RuntimeHelper.SetColorBlock(lockBtn.Component, color, color * 1.2f, color * 0.7f);
|
||||||
|
lockBtn.ButtonText.text = locked ? "Unlock" : "Lock";
|
||||||
|
}
|
||||||
|
|
||||||
|
// UI Construction
|
||||||
|
|
||||||
|
void ConstructUI(GameObject parent)
|
||||||
|
{
|
||||||
|
Text timeLabel = UIFactory.CreateLabel(parent, "TimeLabel", "Time:", TextAnchor.MiddleRight, Color.grey);
|
||||||
|
UIFactory.SetLayoutElement(timeLabel.gameObject, minHeight: 25, minWidth: 35);
|
||||||
|
|
||||||
|
timeInput = UIFactory.CreateInputField(parent, "TimeInput", "timeScale");
|
||||||
|
UIFactory.SetLayoutElement(timeInput.Component.gameObject, minHeight: 25, minWidth: 40);
|
||||||
|
timeInput.Component.GetOnEndEdit().AddListener(OnTimeInputEndEdit);
|
||||||
|
|
||||||
|
timeInput.Text = string.Empty;
|
||||||
|
timeInput.Text = Time.timeScale.ToString();
|
||||||
|
|
||||||
|
lockBtn = UIFactory.CreateButton(parent, "PauseButton", "Lock", new Color(0.2f, 0.2f, 0.2f));
|
||||||
|
UIFactory.SetLayoutElement(lockBtn.Component.gameObject, minHeight: 25, minWidth: 50);
|
||||||
|
lockBtn.OnClick += OnPauseButtonClicked;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only allow Time.timeScale to be set if the user hasn't "locked" it or if we are setting the value internally.
|
||||||
|
|
||||||
|
static void InitPatch()
|
||||||
|
{
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
MethodInfo target = AccessTools.Method(typeof(Time), nameof(Time.timeScale));
|
||||||
|
#if CPP
|
||||||
|
if (UnhollowerBaseLib.UnhollowerUtils.GetIl2CppMethodInfoPointerFieldForGeneratedMethod(target) == null)
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
ExplorerCore.Harmony.Patch(target,
|
||||||
|
prefix: new(AccessTools.Method(typeof(TimeScaleWidget), nameof(Prefix_Time_set_timeScale))));
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool Prefix_Time_set_timeScale()
|
||||||
|
{
|
||||||
|
return !Instance.locked || Instance.settingTimeScale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -79,11 +79,11 @@
|
|||||||
<!-- il2cpp nuget -->
|
<!-- il2cpp nuget -->
|
||||||
<ItemGroup Condition="'$(Configuration)'=='ML_Cpp_net6' or '$(Configuration)'=='ML_Cpp_net472' or '$(Configuration)'=='STANDALONE_Cpp' or '$(Configuration)'=='BIE_Cpp'">
|
<ItemGroup Condition="'$(Configuration)'=='ML_Cpp_net6' or '$(Configuration)'=='ML_Cpp_net472' or '$(Configuration)'=='STANDALONE_Cpp' or '$(Configuration)'=='BIE_Cpp'">
|
||||||
<PackageReference Include="Il2CppAssemblyUnhollower.BaseLib" Version="0.4.22" />
|
<PackageReference Include="Il2CppAssemblyUnhollower.BaseLib" Version="0.4.22" />
|
||||||
<PackageReference Include="UniverseLib.IL2CPP" Version="1.4.1" />
|
<PackageReference Include="UniverseLib.IL2CPP" Version="1.4.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<!-- mono nuget -->
|
<!-- mono nuget -->
|
||||||
<ItemGroup Condition="'$(Configuration)'=='BIE6_Mono' or '$(Configuration)'=='BIE5_Mono' or '$(Configuration)'=='ML_Mono' or '$(Configuration)'=='STANDALONE_Mono'">
|
<ItemGroup Condition="'$(Configuration)'=='BIE6_Mono' or '$(Configuration)'=='BIE5_Mono' or '$(Configuration)'=='ML_Mono' or '$(Configuration)'=='STANDALONE_Mono'">
|
||||||
<PackageReference Include="UniverseLib.Mono" Version="1.4.1" />
|
<PackageReference Include="UniverseLib.Mono" Version="1.4.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- ~~~~~ ASSEMBLY REFERENCES ~~~~~ -->
|
<!-- ~~~~~ ASSEMBLY REFERENCES ~~~~~ -->
|
||||||
|
Reference in New Issue
Block a user