Compare commits

..

12 Commits
1.6.9 ... 1.7.1

Author SHA1 Message Date
065ab033c9 Fix crash when inspecting RigidBody2D objects 2020-09-13 17:39:15 +10:00
11cbd24a6a 1.7.1 2020-09-13 17:29:01 +10:00
fbf9859e0f Fix for GUILayout.BeginArea unstrip and UnityEngine.SystemClock unstrip
and remove some old comments
2020-09-13 17:11:15 +10:00
2d7dfa53eb Fix scroll not working in 2017 games 2020-09-12 16:14:42 +10:00
eff8d63c81 Update README.md 2020-09-12 04:03:53 +10:00
006cf0fc2c Create icon.png 2020-09-12 04:03:30 +10:00
e5ca3530ff Merge branch 'master' of https://github.com/sinai-dev/CppExplorer 2020-09-12 04:01:18 +10:00
4de378907b Update GameObjectWindow.cs 2020-09-12 02:52:52 +10:00
bbdfb46a1e Update README.md 2020-09-12 02:35:41 +10:00
e6e2b3cd67 Update README.md 2020-09-12 02:30:34 +10:00
1d07046a74 Update README.md, hide Console when it fails to init 2020-09-12 02:20:27 +10:00
de663f34b2 1.7.0
* Fix for GuiLayout.Space unstrip
* Cleanups
2020-09-12 00:59:59 +10:00
27 changed files with 412 additions and 233 deletions

View File

@ -1,7 +1,7 @@
# CppExplorer [![Version](https://img.shields.io/badge/MelonLoader-0.2.7.1-green.svg)](https://github.com/HerpDerpinstine/MelonLoader) # CppExplorer [![Version](https://img.shields.io/badge/MelonLoader-0.2.7.1-green.svg)](https://github.com/HerpDerpinstine/MelonLoader)
<p align="center"> <p align="center">
<img align="center" src="https://sinai-dev.github.io/images/thumbs/02.png"> <img align="center" src="icon.png">
</p> </p>
<p align="center"> <p align="center">
@ -13,6 +13,9 @@
<img src="https://img.shields.io/github/downloads/sinai-dev/CppExplorer/total.svg" /> <img src="https://img.shields.io/github/downloads/sinai-dev/CppExplorer/total.svg" />
</p> </p>
<p align="center">
<a href="https://github.com/sinai-dev/MonoExplorer">Looking for a Mono version?</a>
</p>
### Known issues ### Known issues
* CppExplorer may experience a `MissingMethodException` when trying to use certain UnityEngine methods. If you experience this, please open an issue and I will do my best to fix it. * CppExplorer may experience a `MissingMethodException` when trying to use certain UnityEngine methods. If you experience this, please open an issue and I will do my best to fix it.
@ -23,7 +26,7 @@
Requires [MelonLoader](https://github.com/HerpDerpinstine/MelonLoader) to be installed for your game. Requires [MelonLoader](https://github.com/HerpDerpinstine/MelonLoader) to be installed for your game.
1. Download <b>CppExplorer.zip</b> from [Releases](https://github.com/sinaioutlander/CppExplorer/releases). 1. Download <b>CppExplorer.zip</b> from [Releases](https://github.com/sinai-dev/CppExplorer/releases).
2. Unzip the file into the `Mods` folder in your game's installation directory, created by MelonLoader. 2. Unzip the file into the `Mods` folder in your game's installation directory, created by MelonLoader.
3. Make sure it's not in a sub-folder, `CppExplorer.dll` and `mcs.dll` should be directly in the `Mods\` folder. 3. Make sure it's not in a sub-folder, `CppExplorer.dll` and `mcs.dll` should be directly in the `Mods\` folder.

BIN
icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
lib/mcs.NET35.dll Normal file

Binary file not shown.

View File

@ -244,7 +244,6 @@ namespace Explorer
var input = m_argumentInput[i]; var input = m_argumentInput[i];
var type = m_arguments[i].ParameterType; var type = m_arguments[i].ParameterType;
// First, try parse the input and use that.
if (!string.IsNullOrEmpty(input)) if (!string.IsNullOrEmpty(input))
{ {
// strings can obviously just be used directly // strings can obviously just be used directly
@ -384,7 +383,7 @@ namespace Explorer
} }
else else
{ {
GUILayout.Space(labelWidth); GUIUnstrip.Space(labelWidth);
} }
var cm = this as CacheMethod; var cm = this as CacheMethod;
@ -417,21 +416,17 @@ namespace Explorer
} }
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
if (cm != null)
{
if (GUILayout.Button(EVALUATE_LABEL, new GUILayoutOption[] { GUILayout.Width(70) })) if (GUILayout.Button(EVALUATE_LABEL, new GUILayoutOption[] { GUILayout.Width(70) }))
{
if (cm != null)
{ {
cm.Evaluate(); cm.Evaluate();
} }
}
else else
{
if (GUILayout.Button(EVALUATE_LABEL, new GUILayoutOption[] { GUILayout.Width(70) }))
{ {
UpdateValue(); UpdateValue();
} }
} }
if (GUILayout.Button("Cancel", new GUILayoutOption[] { GUILayout.Width(70) })) if (GUILayout.Button("Cancel", new GUILayoutOption[] { GUILayout.Width(70) }))
{ {
m_isEvaluating = false; m_isEvaluating = false;
@ -451,7 +446,7 @@ namespace Explorer
// new line and space // new line and space
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
GUILayout.Space(labelWidth); GUIUnstrip.Space(labelWidth);
} }
else if (cm != null) else if (cm != null)
{ {
@ -465,7 +460,7 @@ namespace Explorer
// new line and space // new line and space
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
GUILayout.Space(labelWidth); GUIUnstrip.Space(labelWidth);
} }
if (!string.IsNullOrEmpty(ReflectionException)) if (!string.IsNullOrEmpty(ReflectionException))

View File

@ -235,7 +235,7 @@ namespace Explorer
} }
GUI.skin.button.alignment = TextAnchor.MiddleCenter; GUI.skin.button.alignment = TextAnchor.MiddleCenter;
GUILayout.Space(5); GUIUnstrip.Space(5);
if (IsExpanded) if (IsExpanded)
{ {
@ -246,7 +246,7 @@ namespace Explorer
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
GUILayout.Space(whitespace); GUIUnstrip.Space(whitespace);
Pages.CurrentPageLabel(); Pages.CurrentPageLabel();
@ -262,7 +262,7 @@ namespace Explorer
Pages.DrawLimitInputArea(); Pages.DrawLimitInputArea();
GUILayout.Space(5); GUIUnstrip.Space(5);
} }
int offset = Pages.CalculateOffsetIndex(); int offset = Pages.CalculateOffsetIndex();
@ -276,7 +276,7 @@ namespace Explorer
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
//GUILayout.Space(whitespace); //GUIUnstrip.Space(whitespace);
if (key == null || val == null) if (key == null || val == null)
{ {

View File

@ -297,7 +297,7 @@ namespace Explorer
} }
GUI.skin.button.alignment = TextAnchor.MiddleCenter; GUI.skin.button.alignment = TextAnchor.MiddleCenter;
GUILayout.Space(5); GUIUnstrip.Space(5);
if (IsExpanded) if (IsExpanded)
{ {
@ -308,7 +308,7 @@ namespace Explorer
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
GUILayout.Space(whitespace); GUIUnstrip.Space(whitespace);
Pages.CurrentPageLabel(); Pages.CurrentPageLabel();
@ -324,7 +324,7 @@ namespace Explorer
Pages.DrawLimitInputArea(); Pages.DrawLimitInputArea();
GUILayout.Space(5); GUIUnstrip.Space(5);
} }
int offset = Pages.CalculateOffsetIndex(); int offset = Pages.CalculateOffsetIndex();
@ -337,7 +337,7 @@ namespace Explorer
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
GUILayout.Space(whitespace); GUIUnstrip.Space(whitespace);
if (entry == null || entry.Value == null) if (entry == null || entry.Value == null)
{ {

View File

@ -61,32 +61,32 @@ namespace Explorer
var whitespace = CalcWhitespace(window); var whitespace = CalcWhitespace(window);
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
GUILayout.Space(whitespace); GUIUnstrip.Space(whitespace);
GUILayout.Label("R:", new GUILayoutOption[] { GUILayout.Width(30) }); GUILayout.Label("R:", new GUILayoutOption[] { GUILayout.Width(30) });
r = GUILayout.TextField(r, new GUILayoutOption[] { GUILayout.Width(120) }); r = GUILayout.TextField(r, new GUILayoutOption[] { GUILayout.Width(120) });
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
GUILayout.Space(whitespace); GUIUnstrip.Space(whitespace);
GUILayout.Label("G:", new GUILayoutOption[] { GUILayout.Width(30) }); GUILayout.Label("G:", new GUILayoutOption[] { GUILayout.Width(30) });
g = GUILayout.TextField(g, new GUILayoutOption[] { GUILayout.Width(120) }); g = GUILayout.TextField(g, new GUILayoutOption[] { GUILayout.Width(120) });
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
GUILayout.Space(whitespace); GUIUnstrip.Space(whitespace);
GUILayout.Label("B:", new GUILayoutOption[] { GUILayout.Width(30) }); GUILayout.Label("B:", new GUILayoutOption[] { GUILayout.Width(30) });
b = GUILayout.TextField(b, new GUILayoutOption[] { GUILayout.Width(120) }); b = GUILayout.TextField(b, new GUILayoutOption[] { GUILayout.Width(120) });
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
GUILayout.Space(whitespace); GUIUnstrip.Space(whitespace);
GUILayout.Label("A:", new GUILayoutOption[] { GUILayout.Width(30) }); GUILayout.Label("A:", new GUILayoutOption[] { GUILayout.Width(30) });
a = GUILayout.TextField(a, new GUILayoutOption[] { GUILayout.Width(120) }); a = GUILayout.TextField(a, new GUILayoutOption[] { GUILayout.Width(120) });
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
// draw set value button // draw set value button
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
GUILayout.Space(whitespace); GUIUnstrip.Space(whitespace);
if (GUILayout.Button("<color=lime>Apply</color>", new GUILayoutOption[] { GUILayout.Width(155) })) if (GUILayout.Button("<color=lime>Apply</color>", new GUILayoutOption[] { GUILayout.Width(155) }))
{ {
SetValueFromInput(); SetValueFromInput();

View File

@ -92,7 +92,7 @@ namespace Explorer
} }
} }
GUILayout.Space(10); GUIUnstrip.Space(10);
} }
} }

View File

@ -56,26 +56,26 @@ namespace Explorer
var whitespace = CalcWhitespace(window); var whitespace = CalcWhitespace(window);
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
GUILayout.Space(whitespace); GUIUnstrip.Space(whitespace);
GUILayout.Label("X:", new GUILayoutOption[] { GUILayout.Width(30) }); GUILayout.Label("X:", new GUILayoutOption[] { GUILayout.Width(30) });
x = GUILayout.TextField(x, new GUILayoutOption[] { GUILayout.Width(120) }); x = GUILayout.TextField(x, new GUILayoutOption[] { GUILayout.Width(120) });
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
GUILayout.Space(whitespace); GUIUnstrip.Space(whitespace);
GUILayout.Label("Y:", new GUILayoutOption[] { GUILayout.Width(30) }); GUILayout.Label("Y:", new GUILayoutOption[] { GUILayout.Width(30) });
y = GUILayout.TextField(y, new GUILayoutOption[] { GUILayout.Width(120) }); y = GUILayout.TextField(y, new GUILayoutOption[] { GUILayout.Width(120) });
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
GUILayout.Space(whitespace); GUIUnstrip.Space(whitespace);
GUILayout.Label("Z:", new GUILayoutOption[] { GUILayout.Width(30) }); GUILayout.Label("Z:", new GUILayoutOption[] { GUILayout.Width(30) });
z = GUILayout.TextField(z, new GUILayoutOption[] { GUILayout.Width(120) }); z = GUILayout.TextField(z, new GUILayoutOption[] { GUILayout.Width(120) });
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
// draw set value button // draw set value button
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
GUILayout.Space(whitespace); GUIUnstrip.Space(whitespace);
if (GUILayout.Button("<color=lime>Apply</color>", new GUILayoutOption[] { GUILayout.Width(155) })) if (GUILayout.Button("<color=lime>Apply</color>", new GUILayoutOption[] { GUILayout.Width(155) }))
{ {
SetValueFromInput(); SetValueFromInput();

View File

@ -58,32 +58,32 @@ namespace Explorer
var whitespace = CalcWhitespace(window); var whitespace = CalcWhitespace(window);
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
GUILayout.Space(whitespace); GUIUnstrip.Space(whitespace);
GUILayout.Label("X:", new GUILayoutOption[] { GUILayout.Width(30) }); GUILayout.Label("X:", new GUILayoutOption[] { GUILayout.Width(30) });
x = GUILayout.TextField(x, new GUILayoutOption[] { GUILayout.Width(120) }); x = GUILayout.TextField(x, new GUILayoutOption[] { GUILayout.Width(120) });
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
GUILayout.Space(whitespace); GUIUnstrip.Space(whitespace);
GUILayout.Label("Y:", new GUILayoutOption[] { GUILayout.Width(30) }); GUILayout.Label("Y:", new GUILayoutOption[] { GUILayout.Width(30) });
y = GUILayout.TextField(y, new GUILayoutOption[] { GUILayout.Width(120) }); y = GUILayout.TextField(y, new GUILayoutOption[] { GUILayout.Width(120) });
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
GUILayout.Space(whitespace); GUIUnstrip.Space(whitespace);
GUILayout.Label("W:", new GUILayoutOption[] { GUILayout.Width(30) }); GUILayout.Label("W:", new GUILayoutOption[] { GUILayout.Width(30) });
w = GUILayout.TextField(w, new GUILayoutOption[] { GUILayout.Width(120) }); w = GUILayout.TextField(w, new GUILayoutOption[] { GUILayout.Width(120) });
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
GUILayout.Space(whitespace); GUIUnstrip.Space(whitespace);
GUILayout.Label("H:", new GUILayoutOption[] { GUILayout.Width(30) }); GUILayout.Label("H:", new GUILayoutOption[] { GUILayout.Width(30) });
h = GUILayout.TextField(h, new GUILayoutOption[] { GUILayout.Width(120) }); h = GUILayout.TextField(h, new GUILayoutOption[] { GUILayout.Width(120) });
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
// draw set value button // draw set value button
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
GUILayout.Space(whitespace); GUIUnstrip.Space(whitespace);
if (GUILayout.Button("<color=lime>Apply</color>", new GUILayoutOption[] { GUILayout.Width(155) })) if (GUILayout.Button("<color=lime>Apply</color>", new GUILayoutOption[] { GUILayout.Width(155) }))
{ {
SetValueFromInput(); SetValueFromInput();

View File

@ -94,13 +94,13 @@ namespace Explorer
// always draw x and y // always draw x and y
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
GUILayout.Space(whitespace); GUIUnstrip.Space(whitespace);
GUILayout.Label("X:", new GUILayoutOption[] { GUILayout.Width(30) }); GUILayout.Label("X:", new GUILayoutOption[] { GUILayout.Width(30) });
x = GUILayout.TextField(x, new GUILayoutOption[] { GUILayout.Width(120) }); x = GUILayout.TextField(x, new GUILayoutOption[] { GUILayout.Width(120) });
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
GUILayout.Space(whitespace); GUIUnstrip.Space(whitespace);
GUILayout.Label("Y:", new GUILayoutOption[] { GUILayout.Width(30) }); GUILayout.Label("Y:", new GUILayoutOption[] { GUILayout.Width(30) });
y = GUILayout.TextField(y, new GUILayoutOption[] { GUILayout.Width(120) }); y = GUILayout.TextField(y, new GUILayoutOption[] { GUILayout.Width(120) });
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
@ -109,7 +109,7 @@ namespace Explorer
{ {
// draw z // draw z
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
GUILayout.Space(whitespace); GUIUnstrip.Space(whitespace);
GUILayout.Label("Z:", new GUILayoutOption[] { GUILayout.Width(30) }); GUILayout.Label("Z:", new GUILayoutOption[] { GUILayout.Width(30) });
z = GUILayout.TextField(z, new GUILayoutOption[] { GUILayout.Width(120) }); z = GUILayout.TextField(z, new GUILayoutOption[] { GUILayout.Width(120) });
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
@ -118,7 +118,7 @@ namespace Explorer
{ {
// draw w // draw w
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
GUILayout.Space(whitespace); GUIUnstrip.Space(whitespace);
GUILayout.Label("W:", new GUILayoutOption[] { GUILayout.Width(30) }); GUILayout.Label("W:", new GUILayoutOption[] { GUILayout.Width(30) });
w = GUILayout.TextField(w, new GUILayoutOption[] { GUILayout.Width(120) }); w = GUILayout.TextField(w, new GUILayoutOption[] { GUILayout.Width(120) });
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
@ -126,7 +126,7 @@ namespace Explorer
// draw set value button // draw set value button
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
GUILayout.Space(whitespace); GUIUnstrip.Space(whitespace);
if (GUILayout.Button("<color=lime>Apply</color>", new GUILayoutOption[] { GUILayout.Width(155) })) if (GUILayout.Button("<color=lime>Apply</color>", new GUILayoutOption[] { GUILayout.Width(155) }))
{ {
SetValueFromInput(); SetValueFromInput();

View File

@ -13,7 +13,7 @@ namespace Explorer
public class CppExplorer : MelonMod public class CppExplorer : MelonMod
{ {
public const string NAME = "CppExplorer"; public const string NAME = "CppExplorer";
public const string VERSION = "1.6.9"; public const string VERSION = "1.7.1";
public const string AUTHOR = "Sinai"; public const string AUTHOR = "Sinai";
public const string GUID = "com.sinai.cppexplorer"; public const string GUID = "com.sinai.cppexplorer";
@ -36,17 +36,13 @@ namespace Explorer
{ {
Instance = this; Instance = this;
// First, load config
ModConfig.OnLoad(); ModConfig.OnLoad();
// Setup InputHelper class (UnityEngine.Input)
InputHelper.Init(); InputHelper.Init();
// Create CppExplorer modules
new MainMenu(); new MainMenu();
new WindowManager(); new WindowManager();
// Init cursor control
CursorControl.Init(); CursorControl.Init();
MelonLogger.Log($"CppExplorer {VERSION} initialized."); MelonLogger.Log($"CppExplorer {VERSION} initialized.");
@ -60,7 +56,6 @@ namespace Explorer
public override void OnUpdate() public override void OnUpdate()
{ {
// Check main toggle key input
if (InputHelper.GetKeyDown(ModConfig.Instance.Main_Menu_Toggle)) if (InputHelper.GetKeyDown(ModConfig.Instance.Main_Menu_Toggle))
{ {
ShowMenu = !ShowMenu; ShowMenu = !ShowMenu;

View File

@ -96,13 +96,14 @@
<Compile Include="Menu\CursorControl.cs" /> <Compile Include="Menu\CursorControl.cs" />
<Compile Include="Tests\TestClass.cs" /> <Compile Include="Tests\TestClass.cs" />
<Compile Include="UnstripFixes\GUIUnstrip.cs" /> <Compile Include="UnstripFixes\GUIUnstrip.cs" />
<Compile Include="UnstripFixes\LayoutUtilityUnstrip.cs" />
<Compile Include="UnstripFixes\ScrollViewStateUnstrip.cs" /> <Compile Include="UnstripFixes\ScrollViewStateUnstrip.cs" />
<Compile Include="Extensions\UnityExtensions.cs" /> <Compile Include="Extensions\UnityExtensions.cs" />
<Compile Include="Helpers\PageHelper.cs" /> <Compile Include="Helpers\PageHelper.cs" />
<Compile Include="Helpers\ReflectionHelpers.cs" /> <Compile Include="Helpers\ReflectionHelpers.cs" />
<Compile Include="Helpers\UIHelpers.cs" /> <Compile Include="Helpers\UIHelpers.cs" />
<Compile Include="Helpers\UnityHelpers.cs" /> <Compile Include="Helpers\UnityHelpers.cs" />
<Compile Include="Menu\MainMenu\InspectUnderMouse.cs" /> <Compile Include="Menu\InspectUnderMouse.cs" />
<Compile Include="CachedObjects\CacheObjectBase.cs" /> <Compile Include="CachedObjects\CacheObjectBase.cs" />
<Compile Include="UnstripFixes\SliderHandlerUnstrip.cs" /> <Compile Include="UnstripFixes\SliderHandlerUnstrip.cs" />
<Compile Include="UnstripFixes\UnstripExtensions.cs" /> <Compile Include="UnstripFixes\UnstripExtensions.cs" />

View File

@ -101,7 +101,6 @@ namespace Explorer
return typeof(ILType); return typeof(ILType);
} }
// Get the System.Type using the qualified name, or fallback to GetType.
return Type.GetType(ilObject.GetIl2CppType().AssemblyQualifiedName) ?? obj.GetType(); return Type.GetType(ilObject.GetIl2CppType().AssemblyQualifiedName) ?? obj.GetType();
} }

View File

@ -24,16 +24,19 @@ namespace Explorer
public static bool ShouldForceMouse => CppExplorer.ShowMenu && ForceUnlockMouse; public static bool ShouldForceMouse => CppExplorer.ShowMenu && ForceUnlockMouse;
private static Type CursorType => m_cursorType ?? (m_cursorType = ReflectionHelpers.GetTypeByName("UnityEngine.Cursor"));
private static Type m_cursorType;
public static void Init() public static void Init()
{ {
try try
{ {
// Check if Cursor class is loaded // Check if Cursor class is loaded
if (ReflectionHelpers.GetTypeByName("UnityEngine.Cursor") == null) if (CursorType == null)
{ {
MelonLogger.Log("Trying to manually load Cursor module..."); MelonLogger.Log("Trying to manually load Cursor module...");
if (ReflectionHelpers.LoadModule("UnityEngine.CoreModule")) if (ReflectionHelpers.LoadModule("UnityEngine.CoreModule") && CursorType != null)
{ {
MelonLogger.Log("Ok!"); MelonLogger.Log("Ok!");
} }
@ -47,11 +50,12 @@ namespace Explorer
m_lastLockMode = Cursor.lockState; m_lastLockMode = Cursor.lockState;
m_lastVisibleState = Cursor.visible; m_lastVisibleState = Cursor.visible;
TryPatch("lockState", new HarmonyMethod(typeof(CursorControl).GetMethod(nameof(Prefix_set_lockState))), false, false); // Setup Harmony Patches
TryPatch("visible", new HarmonyMethod(typeof(CursorControl).GetMethod(nameof(Prefix_set_visible))), false, false); TryPatch("lockState", new HarmonyMethod(typeof(CursorControl).GetMethod(nameof(Prefix_set_lockState))), true);
TryPatch("lockState", new HarmonyMethod(typeof(CursorControl).GetMethod(nameof(Postfix_get_lockState))), false);
TryPatch("lockState", new HarmonyMethod(typeof(CursorControl).GetMethod(nameof(Postfix_get_lockState))), true, true); TryPatch("visible", new HarmonyMethod(typeof(CursorControl).GetMethod(nameof(Prefix_set_visible))), true);
TryPatch("visible", new HarmonyMethod(typeof(CursorControl).GetMethod(nameof(Postfix_get_visible))), true, true); TryPatch("visible", new HarmonyMethod(typeof(CursorControl).GetMethod(nameof(Postfix_get_visible))), false);
} }
catch (Exception e) catch (Exception e)
{ {
@ -64,18 +68,23 @@ namespace Explorer
ForceUnlockMouse = true; ForceUnlockMouse = true;
} }
private static void TryPatch(string property, HarmonyMethod patch, bool getter = true, bool postfix = false) private static void TryPatch(string property, HarmonyMethod patch, bool setter)
{ {
// Setup Harmony Patches
try try
{ {
var harmony = CppExplorer.Instance.harmonyInstance; var harmony = CppExplorer.Instance.harmonyInstance;
var prop = typeof(Cursor).GetProperty(property); var prop = typeof(Cursor).GetProperty(property);
harmony.Patch(getter ? prop.GetGetMethod() : prop.GetSetMethod(), if (setter)
postfix ? null : patch, {
postfix ? patch : null); // setter is prefix
harmony.Patch(prop.GetSetMethod(), patch);
}
else
{
// getter is postfix
harmony.Patch(prop.GetGetMethod(), null, patch);
}
} }
catch (Exception e) catch (Exception e)
{ {
@ -170,69 +179,5 @@ namespace Explorer
__result = m_lastVisibleState; __result = m_lastVisibleState;
} }
} }
//[HarmonyPatch(typeof(Cursor), nameof(Cursor.lockState), MethodType.Setter)]
//public class Cursor_set_lockState
//{
// [HarmonyPrefix]
// public static void Prefix(ref CursorLockMode value)
// {
// if (!m_currentlySettingCursor)
// {
// m_lastLockMode = value;
// if (ShouldForceMouse)
// {
// value = CursorLockMode.None;
// }
// }
// }
//}
//[HarmonyPatch(typeof(Cursor), nameof(Cursor.visible), MethodType.Setter)]
//public class Cursor_set_visible
//{
// [HarmonyPrefix]
// public static void Prefix(ref bool value)
// {
// if (!m_currentlySettingCursor)
// {
// m_lastVisibleState = value;
// if (ShouldForceMouse)
// {
// value = true;
// }
// }
// }
//}
//// Make it appear as though UnlockMouse is disabled to the rest of the application.
//[HarmonyPatch(typeof(Cursor), nameof(Cursor.lockState), MethodType.Getter)]
//public class Cursor_get_lockState
//{
// [HarmonyPostfix]
// public static void Postfix(ref CursorLockMode __result)
// {
// if (ShouldForceMouse)
// {
// __result = m_lastLockMode;
// }
// }
//}
//[HarmonyPatch(typeof(Cursor), nameof(Cursor.visible), MethodType.Getter)]
//public class Cursor_get_visible
//{
// [HarmonyPostfix]
// public static void Postfix(ref bool __result)
// {
// if (ShouldForceMouse)
// {
// __result = m_lastVisibleState;
// }
// }
//}
} }
} }

View File

@ -3,8 +3,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using UnityEngine; using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using MelonLoader; using MelonLoader;
namespace Explorer namespace Explorer
@ -21,8 +19,9 @@ namespace Explorer
Pages.Add(new SearchPage()); Pages.Add(new SearchPage());
Pages.Add(new ConsolePage()); Pages.Add(new ConsolePage());
foreach (var page in Pages) for (int i = 0; i < Pages.Count; i++)
{ {
var page = Pages[i];
page.Init(); page.Init();
} }
} }
@ -30,7 +29,7 @@ namespace Explorer
public const int MainWindowID = 5000; public const int MainWindowID = 5000;
public static Rect MainRect = new Rect(5,5, ModConfig.Instance.Default_Window_Size.x,ModConfig.Instance.Default_Window_Size.y); public static Rect MainRect = new Rect(5,5, ModConfig.Instance.Default_Window_Size.x,ModConfig.Instance.Default_Window_Size.y);
private static readonly List<WindowPage> Pages = new List<WindowPage>(); public static readonly List<WindowPage> Pages = new List<WindowPage>();
private static int m_currentPage = 0; private static int m_currentPage = 0;
public static void SetCurrentPage(int index) public static void SetCurrentPage(int index)
@ -65,7 +64,7 @@ namespace Explorer
return; return;
} }
GUILayout.BeginArea(new Rect(5, 25, MainRect.width - 10, MainRect.height - 35), GUI.skin.box); GUIUnstrip.BeginArea(new Rect(5, 25, MainRect.width - 10, MainRect.height - 35), GUI.skin.box);
MainHeader(); MainHeader();
@ -79,7 +78,7 @@ namespace Explorer
MainRect = ResizeDrag.ResizeWindow(MainRect, MainWindowID); MainRect = ResizeDrag.ResizeWindow(MainRect, MainWindowID);
GUILayout.EndArea(); GUIUnstrip.EndArea();
} }
private void MainHeader() private void MainHeader()
@ -110,7 +109,9 @@ namespace Explorer
WindowManager.TabView = GUILayout.Toggle(WindowManager.TabView, "Tab View", null); WindowManager.TabView = GUILayout.Toggle(WindowManager.TabView, "Tab View", null);
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
GUILayout.Space(10); //GUIUnstrip.Space(10);
GUIUnstrip.Space(10);
GUI.color = Color.white; GUI.color = Color.white;
} }
} }

View File

@ -58,7 +58,9 @@ MelonLogger.Log(""hello world"");";
} }
catch (Exception e) catch (Exception e)
{ {
MelonLogger.Log($"Error setting up console!\r\nMessage: {e.Message}\r\nStack: {e.StackTrace}"); MelonLogger.Log($"Error setting up console!\r\nMessage: {e.Message}");
MainMenu.SetCurrentPage(0);
MainMenu.Pages.Remove(this);
} }
} }

View File

@ -244,7 +244,7 @@ namespace Explorer
} }
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
GUILayout.Space(5); GUIUnstrip.Space(5);
} }
private void SceneChangeButtons() private void SceneChangeButtons()

View File

@ -12,10 +12,12 @@ namespace Explorer
public class GameObjectWindow : UIWindow public class GameObjectWindow : UIWindow
{ {
public override string Title => WindowManager.TabView public override string Title => WindowManager.TabView
? $"<color=cyan>[G]</color> {m_object.name}" ? $"<color=cyan>[G]</color> {TargetGO.name}"
: $"GameObject Inspector ({m_object.name})"; : $"GameObject Inspector ({TargetGO.name})";
public GameObject m_object; public GameObject TargetGO;
private bool m_hideControls;
// gui element holders // gui element holders
private string m_name; private string m_name;
@ -23,11 +25,11 @@ namespace Explorer
private Transform[] m_children; private Transform[] m_children;
private Vector2 m_transformScroll = Vector2.zero; private Vector2 m_transformScroll = Vector2.zero;
private PageHelper ChildPages = new PageHelper(); private readonly PageHelper ChildPages = new PageHelper();
private Component[] m_components; private Component[] m_components;
private Vector2 m_compScroll = Vector2.zero; private Vector2 m_compScroll = Vector2.zero;
private PageHelper CompPages = new PageHelper(); private readonly PageHelper CompPages = new PageHelper();
private readonly Vector3[] m_cachedInput = new Vector3[3]; private readonly Vector3[] m_cachedInput = new Vector3[3];
private float m_translateAmount = 0.3f; private float m_translateAmount = 0.3f;
@ -42,7 +44,7 @@ namespace Explorer
private bool m_localContext; private bool m_localContext;
private readonly List<Component> m_cachedDestroyList = new List<Component>(); private readonly List<Component> m_cachedDestroyList = new List<Component>();
//private string m_addComponentInput = ""; private string m_addComponentInput = "";
private string m_setParentInput = "Enter a GameObject name or path"; private string m_setParentInput = "Enter a GameObject name or path";
@ -52,12 +54,12 @@ namespace Explorer
if (targetType == typeof(GameObject)) if (targetType == typeof(GameObject))
{ {
m_object = Target as GameObject; TargetGO = Target as GameObject;
return true; return true;
} }
else if (targetType == typeof(Transform)) else if (targetType == typeof(Transform))
{ {
m_object = (Target as Transform).gameObject; TargetGO = (Target as Transform).gameObject;
return true; return true;
} }
@ -73,10 +75,10 @@ namespace Explorer
return; return;
} }
m_name = m_object.name; m_name = TargetGO.name;
m_scene = string.IsNullOrEmpty(m_object.scene.name) m_scene = string.IsNullOrEmpty(TargetGO.scene.name)
? "None (Asset/Resource)" ? "None (Asset/Resource)"
: m_object.scene.name; : TargetGO.scene.name;
CacheTransformValues(); CacheTransformValues();
@ -87,15 +89,15 @@ namespace Explorer
{ {
if (m_localContext) if (m_localContext)
{ {
m_cachedInput[0] = m_object.transform.localPosition; m_cachedInput[0] = TargetGO.transform.localPosition;
m_cachedInput[1] = m_object.transform.localEulerAngles; m_cachedInput[1] = TargetGO.transform.localEulerAngles;
} }
else else
{ {
m_cachedInput[0] = m_object.transform.position; m_cachedInput[0] = TargetGO.transform.position;
m_cachedInput[1] = m_object.transform.eulerAngles; m_cachedInput[1] = TargetGO.transform.eulerAngles;
} }
m_cachedInput[2] = m_object.transform.localScale; m_cachedInput[2] = TargetGO.transform.localScale;
} }
public override void Update() public override void Update()
@ -118,7 +120,7 @@ namespace Explorer
} }
} }
if (!m_object && !GetObjectAsGameObject()) if (!TargetGO && !GetObjectAsGameObject())
{ {
throw new Exception("Object is null!"); throw new Exception("Object is null!");
} }
@ -127,22 +129,22 @@ namespace Explorer
{ {
if (m_localContext) if (m_localContext)
{ {
m_object.transform.localPosition = m_frozenPosition; TargetGO.transform.localPosition = m_frozenPosition;
m_object.transform.localRotation = m_frozenRotation; TargetGO.transform.localRotation = m_frozenRotation;
} }
else else
{ {
m_object.transform.position = m_frozenPosition; TargetGO.transform.position = m_frozenPosition;
m_object.transform.rotation = m_frozenRotation; TargetGO.transform.rotation = m_frozenRotation;
} }
m_object.transform.localScale = m_frozenScale; TargetGO.transform.localScale = m_frozenScale;
} }
// update child objects // update child objects
var childList = new List<Transform>(); var childList = new List<Transform>();
for (int i = 0; i < m_object.transform.childCount; i++) for (int i = 0; i < TargetGO.transform.childCount; i++)
{ {
childList.Add(m_object.transform.GetChild(i)); childList.Add(TargetGO.transform.GetChild(i));
} }
childList.Sort((a, b) => b.childCount.CompareTo(a.childCount)); childList.Sort((a, b) => b.childCount.CompareTo(a.childCount));
m_children = childList.ToArray(); m_children = childList.ToArray();
@ -151,7 +153,7 @@ namespace Explorer
// update components // update components
var compList = new Il2CppSystem.Collections.Generic.List<Component>(); var compList = new Il2CppSystem.Collections.Generic.List<Component>();
m_object.GetComponentsInternal(ReflectionHelpers.ComponentType, true, false, true, false, compList); TargetGO.GetComponentsInternal(ReflectionHelpers.ComponentType, true, false, true, false, compList);
m_components = compList.ToArray(); m_components = compList.ToArray();
@ -182,7 +184,7 @@ namespace Explorer
private void ReflectObject(Il2CppSystem.Object obj) private void ReflectObject(Il2CppSystem.Object obj)
{ {
var window = WindowManager.InspectObject(obj, out bool created); var window = WindowManager.InspectObject(obj, out bool created, true);
if (created) if (created)
{ {
@ -210,7 +212,7 @@ namespace Explorer
if (!WindowManager.TabView) if (!WindowManager.TabView)
{ {
Header(); Header();
GUILayout.BeginArea(new Rect(5, 25, rect.width - 10, rect.height - 35), GUI.skin.box); GUIUnstrip.BeginArea(new Rect(5, 25, rect.width - 10, rect.height - 35), GUI.skin.box);
} }
scroll = GUIUnstrip.BeginScrollView(scroll); scroll = GUIUnstrip.BeginScrollView(scroll);
@ -221,7 +223,7 @@ namespace Explorer
{ {
if (GUILayout.Button("<color=#00FF00>Send to Scene View</color>", new GUILayoutOption[] { GUILayout.Width(150) })) if (GUILayout.Button("<color=#00FF00>Send to Scene View</color>", new GUILayoutOption[] { GUILayout.Width(150) }))
{ {
ScenePage.Instance.SetTransformTarget(m_object.transform); ScenePage.Instance.SetTransformTarget(TargetGO.transform);
MainMenu.SetCurrentPage(0); MainMenu.SetCurrentPage(0);
} }
} }
@ -233,12 +235,12 @@ namespace Explorer
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
GUILayout.Label("Path:", new GUILayoutOption[] { GUILayout.Width(50) }); GUILayout.Label("Path:", new GUILayoutOption[] { GUILayout.Width(50) });
string pathlabel = m_object.transform.GetGameObjectPath(); string pathlabel = TargetGO.transform.GetGameObjectPath();
if (m_object.transform.parent != null) if (TargetGO.transform.parent != null)
{ {
if (GUILayout.Button("<-", new GUILayoutOption[] { GUILayout.Width(35) })) if (GUILayout.Button("<-", new GUILayoutOption[] { GUILayout.Width(35) }))
{ {
InspectGameObject(m_object.transform.parent); InspectGameObject(TargetGO.transform.parent);
} }
} }
GUILayout.TextArea(pathlabel, null); GUILayout.TextArea(pathlabel, null);
@ -270,7 +272,7 @@ namespace Explorer
{ {
m_rect = ResizeDrag.ResizeWindow(rect, windowID); m_rect = ResizeDrag.ResizeWindow(rect, windowID);
GUILayout.EndArea(); GUIUnstrip.EndArea();
} }
} }
catch (Exception e) catch (Exception e)
@ -360,6 +362,28 @@ namespace Explorer
} }
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(null);
m_addComponentInput = GUILayout.TextField(m_addComponentInput, new GUILayoutOption[] { GUILayout.Width(130) });
if (GUILayout.Button("Add Comp", null))
{
if (ReflectionHelpers.GetTypeByName(m_addComponentInput) is Type compType)
{
if (typeof(Component).IsAssignableFrom(compType))
{
TargetGO.AddComponent(Il2CppType.From(compType));
}
else
{
MelonLogger.LogWarning($"Type '{compType.Name}' is not assignable from Component!");
}
}
else
{
MelonLogger.LogWarning($"Could not find a type by the name of '{m_addComponentInput}'!");
}
}
GUILayout.EndHorizontal();
GUI.skin.button.alignment = TextAnchor.MiddleLeft; GUI.skin.button.alignment = TextAnchor.MiddleLeft;
if (m_cachedDestroyList.Count > 0) if (m_cachedDestroyList.Count > 0)
{ {
@ -385,7 +409,7 @@ namespace Explorer
} }
else else
{ {
GUILayout.Space(26); GUIUnstrip.Space(26);
} }
if (GUILayout.Button("<color=cyan>" + ilType.Name + "</color>", new GUILayoutOption[] { GUILayout.Width(m_rect.width / 2 - 100) })) if (GUILayout.Button("<color=cyan>" + ilType.Name + "</color>", new GUILayoutOption[] { GUILayout.Width(m_rect.width / 2 - 100) }))
{ {
@ -439,21 +463,41 @@ namespace Explorer
private void GameObjectControls() private void GameObjectControls()
{ {
if (m_hideControls)
{
GUILayout.BeginHorizontal(null);
GUILayout.Label("<b><size=15>GameObject Controls</size></b>", new GUILayoutOption[] { GUILayout.Width(200) });
if (GUILayout.Button("^ Show ^", new GUILayoutOption[] { GUILayout.Width(75) }))
{
m_hideControls = false;
}
GUILayout.EndHorizontal();
return;
}
GUILayout.BeginVertical(GUI.skin.box, new GUILayoutOption[] { GUILayout.Width(520) }); GUILayout.BeginVertical(GUI.skin.box, new GUILayoutOption[] { GUILayout.Width(520) });
GUILayout.Label("<b><size=15>GameObject Controls</size></b>", null);
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
bool m_active = m_object.activeSelf; GUILayout.Label("<b><size=15>GameObject Controls</size></b>", new GUILayoutOption[] { GUILayout.Width(200) });
if (GUILayout.Button("v Hide v", new GUILayoutOption[] { GUILayout.Width(75) }))
{
m_hideControls = true;
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(null);
bool m_active = TargetGO.activeSelf;
m_active = GUILayout.Toggle(m_active, (m_active ? "<color=lime>Enabled " : "<color=red>Disabled") + "</color>", m_active = GUILayout.Toggle(m_active, (m_active ? "<color=lime>Enabled " : "<color=red>Disabled") + "</color>",
new GUILayoutOption[] { GUILayout.Width(80) }); new GUILayoutOption[] { GUILayout.Width(80) });
if (m_object.activeSelf != m_active) { m_object.SetActive(m_active); } if (TargetGO.activeSelf != m_active) { TargetGO.SetActive(m_active); }
UIHelpers.InstantiateButton(m_object, 100); UIHelpers.InstantiateButton(TargetGO, 100);
if (GUILayout.Button("Set DontDestroyOnLoad", new GUILayoutOption[] { GUILayout.Width(170) })) if (GUILayout.Button("Set DontDestroyOnLoad", new GUILayoutOption[] { GUILayout.Width(170) }))
{ {
GameObject.DontDestroyOnLoad(m_object); GameObject.DontDestroyOnLoad(TargetGO);
m_object.hideFlags |= HideFlags.DontUnloadUnusedAsset; TargetGO.hideFlags |= HideFlags.DontUnloadUnusedAsset;
} }
var lbl = m_freeze ? "<color=lime>Unfreeze</color>" : "<color=orange>Freeze Pos/Rot</color>"; var lbl = m_freeze ? "<color=lime>Unfreeze</color>" : "<color=orange>Freeze Pos/Rot</color>";
@ -474,7 +518,7 @@ namespace Explorer
{ {
if (GameObject.Find(m_setParentInput) is GameObject newparent) if (GameObject.Find(m_setParentInput) is GameObject newparent)
{ {
m_object.transform.parent = newparent.transform; TargetGO.transform.parent = newparent.transform;
} }
else else
{ {
@ -484,7 +528,7 @@ namespace Explorer
if (GUILayout.Button("Detach from parent", new GUILayoutOption[] { GUILayout.Width(160) })) if (GUILayout.Button("Detach from parent", new GUILayoutOption[] { GUILayout.Width(160) }))
{ {
m_object.transform.parent = null; TargetGO.transform.parent = null;
} }
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
@ -499,15 +543,15 @@ namespace Explorer
{ {
if (m_localContext) if (m_localContext)
{ {
m_object.transform.localPosition = m_cachedInput[0]; TargetGO.transform.localPosition = m_cachedInput[0];
m_object.transform.localEulerAngles = m_cachedInput[1]; TargetGO.transform.localEulerAngles = m_cachedInput[1];
} }
else else
{ {
m_object.transform.position = m_cachedInput[0]; TargetGO.transform.position = m_cachedInput[0];
m_object.transform.eulerAngles = m_cachedInput[1]; TargetGO.transform.eulerAngles = m_cachedInput[1];
} }
m_object.transform.localScale = m_cachedInput[2]; TargetGO.transform.localScale = m_cachedInput[2];
if (m_freeze) if (m_freeze)
{ {
@ -541,7 +585,7 @@ namespace Explorer
if (GUILayout.Button("<color=red><b>Destroy</b></color>", new GUILayoutOption[] { GUILayout.Width(120) })) if (GUILayout.Button("<color=red><b>Destroy</b></color>", new GUILayoutOption[] { GUILayout.Width(120) }))
{ {
GameObject.Destroy(m_object); GameObject.Destroy(TargetGO);
DestroyWindow(); DestroyWindow();
return; return;
} }
@ -553,15 +597,15 @@ namespace Explorer
{ {
if (m_localContext) if (m_localContext)
{ {
m_frozenPosition = m_object.transform.localPosition; m_frozenPosition = TargetGO.transform.localPosition;
m_frozenRotation = m_object.transform.localRotation; m_frozenRotation = TargetGO.transform.localRotation;
} }
else else
{ {
m_frozenPosition = m_object.transform.position; m_frozenPosition = TargetGO.transform.position;
m_frozenRotation = m_object.transform.rotation; m_frozenRotation = TargetGO.transform.rotation;
} }
m_frozenScale = m_object.transform.localScale; m_frozenScale = TargetGO.transform.localScale;
} }
private void BoolToggle(ref bool value, string message) private void BoolToggle(ref bool value, string message)
@ -586,7 +630,7 @@ namespace Explorer
GUILayout.Label($"<color=cyan><b>{(m_localContext ? "Local " : "")}{mode}</b></color>:", GUILayout.Label($"<color=cyan><b>{(m_localContext ? "Local " : "")}{mode}</b></color>:",
new GUILayoutOption[] { GUILayout.Width(m_localContext ? 110 : 65) }); new GUILayoutOption[] { GUILayout.Width(m_localContext ? 110 : 65) });
var transform = m_object.transform; var transform = TargetGO.transform;
switch (mode) switch (mode)
{ {
case TranslateType.Position: case TranslateType.Position:

View File

@ -36,13 +36,15 @@ namespace Explorer
{ {
// Causes a crash // Causes a crash
"Type.DeclaringMethod", "Type.DeclaringMethod",
// Causes a crash
"Rigidbody2D.Cast",
}; };
private static readonly HashSet<string> _methodStartsWithBlacklist = new HashSet<string> private static readonly HashSet<string> _methodStartsWithBlacklist = new HashSet<string>
{ {
// Pointless (handled by Properties) // Pointless (handled by Properties)
"get_", "get_",
"set_" "set_",
}; };
public override void Init() public override void Init()
@ -194,6 +196,8 @@ namespace Explorer
continue; continue;
} }
// MelonLogger.Log($"Trying to cache member {signature}...");
try try
{ {
var cached = CacheObjectBase.GetCacheObject(member, target); var cached = CacheObjectBase.GetCacheObject(member, target);
@ -228,7 +232,7 @@ namespace Explorer
if (!WindowManager.TabView) if (!WindowManager.TabView)
{ {
Header(); Header();
GUILayout.BeginArea(new Rect(5, 25, rect.width - 10, rect.height - 35), GUI.skin.box); GUIUnstrip.BeginArea(new Rect(5, 25, rect.width - 10, rect.height - 35), GUI.skin.box);
} }
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
@ -288,7 +292,7 @@ namespace Explorer
GUI.color = Color.white; GUI.color = Color.white;
GUILayout.EndHorizontal(); GUILayout.EndHorizontal();
GUILayout.Space(10); GUIUnstrip.Space(10);
Pages.ItemCount = m_cachedMembersFiltered.Length; Pages.ItemCount = m_cachedMembersFiltered.Length;
@ -317,7 +321,7 @@ namespace Explorer
scroll = GUIUnstrip.BeginScrollView(scroll); scroll = GUIUnstrip.BeginScrollView(scroll);
GUILayout.Space(10); GUIUnstrip.Space(10);
UIStyles.HorizontalLine(Color.grey); UIStyles.HorizontalLine(Color.grey);
@ -354,7 +358,7 @@ namespace Explorer
{ {
m_rect = ResizeDrag.ResizeWindow(rect, windowID); m_rect = ResizeDrag.ResizeWindow(rect, windowID);
GUILayout.EndArea(); GUIUnstrip.EndArea();
} }
} }
catch (Il2CppException e) catch (Il2CppException e)

View File

@ -32,7 +32,7 @@ namespace Explorer
GUILayout.Button(gcDrag, GUI.skin.label, new GUILayoutOption[] { GUILayout.Height(15) }); GUILayout.Button(gcDrag, GUI.skin.label, new GUILayoutOption[] { GUILayout.Height(15) });
//var r = GUILayoutUtility.GetLastRect(); //var r = GUILayoutUtility.GetLastRect();
var r = GUIUnstrip.GetLastRect(); var r = LayoutUtilityUnstrip.GetLastRect();
var mousePos = InputHelper.mousePosition; var mousePos = InputHelper.mousePosition;

View File

@ -65,7 +65,7 @@ namespace Explorer
return; return;
} }
GUILayout.BeginArea(new Rect(5, 25, m_rect.width - 10, m_rect.height - 35), GUI.skin.box); GUIUnstrip.BeginArea(new Rect(5, 25, m_rect.width - 10, m_rect.height - 35), GUI.skin.box);
GUILayout.BeginVertical(GUI.skin.box, null); GUILayout.BeginVertical(GUI.skin.box, null);
GUILayout.BeginHorizontal(null); GUILayout.BeginHorizontal(null);
@ -109,7 +109,7 @@ namespace Explorer
} }
catch { } catch { }
GUILayout.EndArea(); GUIUnstrip.EndArea();
} }
catch { } catch { }
} }

View File

@ -8,7 +8,6 @@ using UnhollowerBaseLib;
using UnhollowerRuntimeLib; using UnhollowerRuntimeLib;
using UnityEngine; using UnityEngine;
using UnityEngine.Events; using UnityEngine.Events;
using UnityEngine.EventSystems;
namespace Explorer namespace Explorer
{ {

View File

@ -20,42 +20,123 @@ namespace Explorer
public static bool ScrollFailed = false; public static bool ScrollFailed = false;
public static bool ManualUnstripFailed = false; public static bool ManualUnstripFailed = false;
private static GenericStack ScrollStack private static GenericStack ScrollStack => m_scrollStack ?? GetScrollStack();
{ private static PropertyInfo m_scrollViewStatesInfo;
get private static GenericStack m_scrollStack;
public static DateTime nextScrollStepTime;
private static GenericStack GetScrollStack()
{ {
if (m_scrollViewStatesInfo == null) if (m_scrollViewStatesInfo == null)
{ {
try if (typeof(GUI).GetProperty("scrollViewStates", ReflectionHelpers.CommonFlags) is PropertyInfo scrollStatesInfo)
{ {
m_scrollViewStatesInfo = typeof(GUI).GetProperty("scrollViewStates"); m_scrollViewStatesInfo = scrollStatesInfo;
if (m_scrollViewStatesInfo == null) throw new Exception();
} }
catch else if (typeof(GUI).GetProperty("s_ScrollViewStates", ReflectionHelpers.CommonFlags) is PropertyInfo s_scrollStatesInfo)
{ {
m_scrollViewStatesInfo = typeof(GUI).GetProperty("s_scrollViewStates"); m_scrollViewStatesInfo = s_scrollStatesInfo;
} }
} }
return (GenericStack)m_scrollViewStatesInfo?.GetValue(null, null); if (m_scrollViewStatesInfo?.GetValue(null, null) is GenericStack stack)
}
}
private static PropertyInfo m_scrollViewStatesInfo;
public static Rect GetLastRect()
{ {
EventType type = Event.current.type; m_scrollStack = stack;
Rect last;
if (type != EventType.Layout && type != EventType.Used)
{
last = GUILayoutUtility.current.topLevel.GetLastUnstripped();
} }
else else
{ {
last = GUILayoutUtility.kDummyRect; m_scrollStack = new GenericStack();
} }
return last;
return m_scrollStack;
}
public static void Space(float pixels)
{
GUIUtility.CheckOnGUI();
if (GUILayoutUtility.current.topLevel.isVertical)
LayoutUtilityUnstrip.GetRect(0, pixels, GUILayoutUtility.spaceStyle, new GUILayoutOption[] { GUILayout.Height(pixels) });
else
LayoutUtilityUnstrip.GetRect(pixels, 0, GUILayoutUtility.spaceStyle, new GUILayoutOption[] { GUILayout.Width(pixels) });
if (Event.current.type == EventType.Layout)
{
GUILayoutUtility.current.topLevel.entries[GUILayoutUtility.current.topLevel.entries.Count - 1].consideredForMargin = false;
}
}
// Fix for BeginArea
static public void BeginArea(Rect screenRect) { BeginArea(screenRect, GUIContent.none, GUIStyle.none); }
static public void BeginArea(Rect screenRect, string text) { BeginArea(screenRect, GUIContent.Temp(text), GUIStyle.none); }
static public void BeginArea(Rect screenRect, Texture image) { BeginArea(screenRect, GUIContent.Temp(image), GUIStyle.none); }
static public void BeginArea(Rect screenRect, GUIContent content) { BeginArea(screenRect, content, GUIStyle.none); }
static public void BeginArea(Rect screenRect, GUIStyle style) { BeginArea(screenRect, GUIContent.none, style); }
static public void BeginArea(Rect screenRect, string text, GUIStyle style) { BeginArea(screenRect, GUIContent.Temp(text), style); }
static public void BeginArea(Rect screenRect, Texture image, GUIStyle style) { BeginArea(screenRect, GUIContent.Temp(image), style); }
// Begin a GUILayout block of GUI controls in a fixed screen area.
static public void BeginArea(Rect screenRect, GUIContent content, GUIStyle style)
{
GUILayoutGroup g = GUILayoutUtility.BeginLayoutArea(style, Il2CppType.Of<GUILayoutGroup>());
if (Event.current.type == EventType.Layout)
{
g.resetCoords = true;
g.minWidth = g.maxWidth = screenRect.width;
g.minHeight = g.maxHeight = screenRect.height;
g.rect = Rect.MinMaxRect(screenRect.xMin, screenRect.yMin, g.rect.xMax, g.rect.yMax);
}
GUI.BeginGroup(g.rect, content, style);
}
// Close a GUILayout block started with BeginArea
static public void EndArea()
{
if (Event.current.type == EventType.Used)
return;
GUILayoutUtility.current.layoutGroups.Pop();
GUILayoutUtility.current.topLevel = GUILayoutUtility.current.layoutGroups.Peek().TryCast<GUILayoutGroup>();
GUI.EndGroup();
}
// Fix for BeginGroup
public static void BeginGroup(Rect position) { BeginGroup(position, GUIContent.none, GUIStyle.none); }
public static void BeginGroup(Rect position, string text) { BeginGroup(position, GUIContent.Temp(text), GUIStyle.none); }
public static void BeginGroup(Rect position, Texture image) { BeginGroup(position, GUIContent.Temp(image), GUIStyle.none); }
public static void BeginGroup(Rect position, GUIContent content) { BeginGroup(position, content, GUIStyle.none); }
public static void BeginGroup(Rect position, GUIStyle style) { BeginGroup(position, GUIContent.none, style); }
public static void BeginGroup(Rect position, string text, GUIStyle style) { BeginGroup(position, GUIContent.Temp(text), style); }
public static void BeginGroup(Rect position, Texture image, GUIStyle style) { BeginGroup(position, GUIContent.Temp(image), style); }
public static void BeginGroup(Rect position, GUIContent content, GUIStyle style) { BeginGroup(position, content, style, Vector2.zero); }
internal static void BeginGroup(Rect position, GUIContent content, GUIStyle style, Vector2 scrollOffset)
{
int id = GUIUtility.GetControlID(GUI.s_BeginGroupHash, FocusType.Passive);
if (content != GUIContent.none || style != GUIStyle.none)
{
switch (Event.current.type)
{
case EventType.Repaint:
style.Draw(position, content, id);
break;
default:
if (position.Contains(Event.current.mousePosition))
GUIUtility.mouseUsed = true;
break;
}
}
GUIClip.Push(position, scrollOffset, Vector2.zero, false);
}
public static void EndGroup()
{
GUIClip.Internal_Pop();
} }
// Fix for BeginScrollView. // Fix for BeginScrollView.
@ -112,8 +193,6 @@ namespace Explorer
private static Vector2 BeginScrollView_ImplLayout(Vector2 scrollPosition, bool alwaysShowHorizontal, bool alwaysShowVertical, private static Vector2 BeginScrollView_ImplLayout(Vector2 scrollPosition, bool alwaysShowHorizontal, bool alwaysShowVertical,
GUIStyle horizontalScrollbar, GUIStyle verticalScrollbar, GUIStyle background, params GUILayoutOption[] options) GUIStyle horizontalScrollbar, GUIStyle verticalScrollbar, GUIStyle background, params GUILayoutOption[] options)
{ {
GUIUtility.CheckOnGUI();
var guiscrollGroup = GUILayoutUtility.BeginLayoutGroup(background, null, Il2CppType.Of<GUIScrollGroup>()) var guiscrollGroup = GUILayoutUtility.BeginLayoutGroup(background, null, Il2CppType.Of<GUIScrollGroup>())
.TryCast<GUIScrollGroup>(); .TryCast<GUIScrollGroup>();
@ -145,7 +224,7 @@ namespace Explorer
private static Vector2 BeginScrollView_Impl(Rect position, Vector2 scrollPosition, Rect viewRect, bool alwaysShowHorizontal, private static Vector2 BeginScrollView_Impl(Rect position, Vector2 scrollPosition, Rect viewRect, bool alwaysShowHorizontal,
bool alwaysShowVertical, GUIStyle horizontalScrollbar, GUIStyle verticalScrollbar, GUIStyle background) bool alwaysShowVertical, GUIStyle horizontalScrollbar, GUIStyle verticalScrollbar, GUIStyle background)
{ {
GUIUtility.CheckOnGUI(); // GUIUtility.CheckOnGUI();
int controlID = GUIUtility.GetControlID(GUI.s_ScrollviewHash, FocusType.Passive); int controlID = GUIUtility.GetControlID(GUI.s_ScrollviewHash, FocusType.Passive);
@ -388,12 +467,12 @@ namespace Explorer
if (flag) if (flag)
{ {
result = true; result = true;
GUI.nextScrollStepTime = Il2CppSystem.DateTime.Now.AddMilliseconds(250.0); nextScrollStepTime = DateTime.Now.AddMilliseconds(250.0);
} }
else if (Il2CppSystem.DateTime.Now >= GUI.nextScrollStepTime) else if (DateTime.Now >= nextScrollStepTime)
{ {
result = true; result = true;
GUI.nextScrollStepTime = Il2CppSystem.DateTime.Now.AddMilliseconds(30.0); nextScrollStepTime = DateTime.Now.AddMilliseconds(30.0);
} }
if (Event.current.type == EventType.Repaint) if (Event.current.type == EventType.Repaint)
{ {

View File

@ -0,0 +1,112 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace Explorer
{
public class LayoutUtilityUnstrip
{
public static Rect GetRect(float width, float height) { return DoGetRect(width, width, height, height, GUIStyle.none, null); }
public static Rect GetRect(float width, float height, GUIStyle style) { return DoGetRect(width, width, height, height, style, null); }
public static Rect GetRect(float width, float height, params GUILayoutOption[] options) { return DoGetRect(width, width, height, height, GUIStyle.none, options); }
// Reserve layout space for a rectangle with a fixed content area.
public static Rect GetRect(float width, float height, GUIStyle style, params GUILayoutOption[] options)
{ return DoGetRect(width, width, height, height, style, options); }
public static Rect GetRect(float minWidth, float maxWidth, float minHeight, float maxHeight)
{ return DoGetRect(minWidth, maxWidth, minHeight, maxHeight, GUIStyle.none, null); }
public static Rect GetRect(float minWidth, float maxWidth, float minHeight, float maxHeight, GUIStyle style)
{ return DoGetRect(minWidth, maxWidth, minHeight, maxHeight, style, null); }
public static Rect GetRect(float minWidth, float maxWidth, float minHeight, float maxHeight, params GUILayoutOption[] options)
{ return DoGetRect(minWidth, maxWidth, minHeight, maxHeight, GUIStyle.none, options); }
// Reserve layout space for a flexible rect.
public static Rect GetRect(float minWidth, float maxWidth, float minHeight, float maxHeight, GUIStyle style, params GUILayoutOption[] options)
{ return DoGetRect(minWidth, maxWidth, minHeight, maxHeight, style, options); }
static Rect DoGetRect(float minWidth, float maxWidth, float minHeight, float maxHeight, GUIStyle style, GUILayoutOption[] options)
{
switch (Event.current.type)
{
case EventType.Layout:
GUILayoutUtility.current.topLevel.Add(new GUILayoutEntry(minWidth, maxWidth, minHeight, maxHeight, style, options));
return GUILayoutUtility.kDummyRect;
case EventType.Used:
return GUILayoutUtility.kDummyRect;
default:
return GUILayoutUtility.current.topLevel.GetNext().rect;
}
}
public static Rect GetRect(GUIContent content, GUIStyle style) { return DoGetRect(content, style, null); }
// Reserve layout space for a rectangle for displaying some contents with a specific style.
public static Rect GetRect(GUIContent content, GUIStyle style, params GUILayoutOption[] options) { return DoGetRect(content, style, options); }
static Rect DoGetRect(GUIContent content, GUIStyle style, GUILayoutOption[] options)
{
GUIUtility.CheckOnGUI();
switch (Event.current.type)
{
case EventType.Layout:
if (style.isHeightDependantOnWidth)
{
GUILayoutUtility.current.topLevel.Add(new GUIWordWrapSizer(style, content, options));
}
else
{
Vector2 sizeConstraints = new Vector2(0, 0);
if (options != null)
{
foreach (var option in options)
{
if (float.TryParse(option.value.ToString(), out float f))
{
switch (option.type)
{
case GUILayoutOption.Type.maxHeight:
sizeConstraints.y = f;
break;
case GUILayoutOption.Type.maxWidth:
sizeConstraints.x = f;
break;
}
}
}
}
Vector2 size = style.CalcSizeWithConstraints(content, sizeConstraints);
// This is needed on non-integer scale ratios to avoid errors to accumulate in further layout calculations
size.x = Mathf.Ceil(size.x);
size.y = Mathf.Ceil(size.y);
GUILayoutUtility.current.topLevel.Add(new GUILayoutEntry(size.x, size.x, size.y, size.y, style, options));
}
return GUILayoutUtility.kDummyRect;
case EventType.Used:
return GUILayoutUtility.kDummyRect;
default:
var entry = GUILayoutUtility.current.topLevel.GetNext();
//GUIDebugger.LogLayoutEntry(entry.rect, entry.marginLeft, entry.marginRight, entry.marginTop, entry.marginBottom, entry.style);
return entry.rect;
}
}
public static Rect GetLastRect()
{
EventType type = Event.current.type;
Rect last;
if (type != EventType.Layout && type != EventType.Used)
{
last = GUILayoutUtility.current.topLevel.GetLastUnstripped();
}
else
{
last = GUILayoutUtility.kDummyRect;
}
return last;
}
}
}

View File

@ -81,7 +81,7 @@ namespace Explorer
if (this.SupportsPageMovements()) if (this.SupportsPageMovements())
{ {
this.SliderState().isDragging = false; this.SliderState().isDragging = false;
GUI.nextScrollStepTime = SystemClock.now.AddMilliseconds(250.0); GUIUnstrip.nextScrollStepTime = DateTime.Now.AddMilliseconds(250.0);
GUI.scrollTroughSide = this.CurrentScrollTroughSide(); GUI.scrollTroughSide = this.CurrentScrollTroughSide();
result = this.PageMovementValue(); result = this.PageMovementValue();
} }
@ -155,7 +155,7 @@ namespace Explorer
else else
{ {
GUI.InternalRepaintEditorWindow(); GUI.InternalRepaintEditorWindow();
if (SystemClock.now < GUI.nextScrollStepTime) if (DateTime.Now < GUIUnstrip.nextScrollStepTime)
{ {
result = this.currentValue; result = this.currentValue;
} }
@ -165,7 +165,7 @@ namespace Explorer
} }
else else
{ {
GUI.nextScrollStepTime = SystemClock.now.AddMilliseconds(30.0); GUIUnstrip.nextScrollStepTime = DateTime.Now.AddMilliseconds(30.0);
if (this.SupportsPageMovements()) if (this.SupportsPageMovements())
{ {
this.SliderState().isDragging = false; this.SliderState().isDragging = false;