mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-05 04:42:54 +08:00
Compare commits
31 Commits
Author | SHA1 | Date | |
---|---|---|---|
6ea435deee | |||
94f749342d | |||
0769b7ef23 | |||
5086dcc82b | |||
56abd38e92 | |||
a7e6ae87df | |||
b5c584bb02 | |||
c8a3aecdf4 | |||
33c2378f41 | |||
38aafa7e5b | |||
4bb0811b2c | |||
4aefe1c5a3 | |||
c228d29707 | |||
56d1507aff | |||
72d31eaa64 | |||
4e8b84b67e | |||
5b94e31a12 | |||
692a37635e | |||
9cb1cea025 | |||
e13f198815 | |||
9a059c1056 | |||
ffb6cad8c2 | |||
d0a4863139 | |||
bb8837d58c | |||
a236b272c1 | |||
18de1eaf1c | |||
b1264c6912 | |||
9836566e55 | |||
d20461fa0e | |||
72ec34090d | |||
883a8705c3 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -9,6 +9,7 @@
|
|||||||
*.user
|
*.user
|
||||||
*.userosscache
|
*.userosscache
|
||||||
*.sln.docstates
|
*.sln.docstates
|
||||||
|
*/mcs-unity*
|
||||||
|
|
||||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
*.userprefs
|
*.userprefs
|
||||||
|
53
README.md
53
README.md
@ -1,4 +1,4 @@
|
|||||||
# CppExplorer []()
|
# CppExplorer [](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="https://sinai-dev.github.io/images/thumbs/02.png">
|
||||||
@ -14,18 +14,10 @@
|
|||||||
<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>
|
||||||
|
|
||||||
### Known issue
|
### Known issues
|
||||||
Some games are experiencing `MissingMethodException`s or exceptions about failed unstripping, which prevent the CppExplorer menu from showing properly or at all. This is a bug with [Il2CppAssemblyUnhollower](https://github.com/knah/Il2CppAssemblyUnhollower) and there isn't much I can do about it myself.
|
* 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.
|
||||||
|
* Reflection may fail with certain types (eg. `Nullable<T>`, some Dictionary types, etc). Please see [Il2CppAssemblyUnhollower](https://github.com/knah/Il2CppAssemblyUnhollower#known-issues) for more details.
|
||||||
If you're familiar with C# and Unity, one possibility for now is making a fork of this repo and manually fixing all the broken methods to ones which aren't broken (if possible). There may be another overload of the same method which wasn't stripped or was unstripped successfully, which you can use instead.
|
* Scrolling with mouse wheel in the CppExplorer menu may not work on all games at the moment.
|
||||||
|
|
||||||
## Features
|
|
||||||
* Scene hierarchy explorer
|
|
||||||
* Search loaded assets with filters
|
|
||||||
* Traverse and manipulate GameObjects
|
|
||||||
* Generic Reflection inspector
|
|
||||||
* C# REPL Console
|
|
||||||
* Inspect-under-mouse
|
|
||||||
|
|
||||||
## How to install
|
## How to install
|
||||||
|
|
||||||
@ -40,13 +32,23 @@ Requires [MelonLoader](https://github.com/HerpDerpinstine/MelonLoader) to be ins
|
|||||||
* Press F7 to show or hide the menu.
|
* Press F7 to show or hide the menu.
|
||||||
* Simply browse through the scene, search for objects, etc, most of it is pretty self-explanatory.
|
* Simply browse through the scene, search for objects, etc, most of it is pretty self-explanatory.
|
||||||
|
|
||||||
|
### Features
|
||||||
|
[](img.png)
|
||||||
|
|
||||||
|
<i>An overview of the different CppExplorer menus.</i>
|
||||||
|
|
||||||
|
* Scene hierarchy explorer
|
||||||
|
* Search loaded assets with filters
|
||||||
|
* Traverse and manipulate GameObjects
|
||||||
|
* Generic Reflection inspector
|
||||||
|
* C# REPL Console
|
||||||
|
* Inspect-under-mouse
|
||||||
|
|
||||||
### Scene Explorer
|
### Scene Explorer
|
||||||
|
|
||||||
* A simple menu which allows you to traverse the Transform heirarchy of the scene.
|
* A simple menu which allows you to traverse the Transform heirarchy of the scene.
|
||||||
* Click on a GameObject to set it as the current path, or <b>Inspect</b> it to send it to an Inspector Window.
|
* Click on a GameObject to set it as the current path, or <b>Inspect</b> it to send it to an Inspector Window.
|
||||||
|
|
||||||
[](https://i.imgur.com/2b0q0jL.png)
|
|
||||||
|
|
||||||
### Inspectors
|
### Inspectors
|
||||||
|
|
||||||
CppExplorer has two main inspector modes: <b>GameObject Inspector</b>, and <b>Reflection Inspector</b>.
|
CppExplorer has two main inspector modes: <b>GameObject Inspector</b>, and <b>Reflection Inspector</b>.
|
||||||
@ -60,30 +62,22 @@ CppExplorer has two main inspector modes: <b>GameObject Inspector</b>, and <b>Re
|
|||||||
* Allows you to see the children and components on a GameObject.
|
* Allows you to see the children and components on a GameObject.
|
||||||
* Can use some basic GameObject Controls such as translating and rotating the object, destroy it, clone it, etc.
|
* Can use some basic GameObject Controls such as translating and rotating the object, destroy it, clone it, etc.
|
||||||
|
|
||||||
[](https://i.imgur.com/JTxqlx4.png)
|
|
||||||
|
|
||||||
### Reflection Inspector
|
### Reflection Inspector
|
||||||
|
|
||||||
* The Reflection Inspector is used for all other supported objects.
|
* The Reflection Inspector is used for all other supported objects.
|
||||||
* Allows you to inspect Properties, Fields and basic Methods, as well as set primitive values and evaluate primitive methods.
|
* Allows you to inspect Properties, Fields and basic Methods, as well as set primitive values and evaluate primitive methods.
|
||||||
* Can search and filter members for the ones you are interested in.
|
* Can search and filter members for the ones you are interested in.
|
||||||
|
|
||||||
[](https://i.imgur.com/iq92m0l.png)
|
|
||||||
|
|
||||||
### Object Search
|
### Object Search
|
||||||
|
|
||||||
* You can search for an `UnityEngine.Object` with the Object Search feature.
|
* You can search for an `UnityEngine.Object` with the Object Search feature.
|
||||||
* Filter by name, type, etc.
|
* Filter by name, type, etc.
|
||||||
* For GameObjects and Transforms you can filter which scene they are found in too.
|
* For GameObjects and Transforms you can filter which scene they are found in too.
|
||||||
|
|
||||||
[](https://i.imgur.com/lK2RthM.png)
|
|
||||||
|
|
||||||
### C# REPL console
|
### C# REPL console
|
||||||
|
|
||||||
* A simple C# REPL console, allows you to execute a method body on the fly.
|
* A simple C# REPL console, allows you to execute a method body on the fly.
|
||||||
|
|
||||||
[](https://i.imgur.com/5U4D1a8.png)
|
|
||||||
|
|
||||||
### Inspect-under-mouse
|
### Inspect-under-mouse
|
||||||
|
|
||||||
* Press Shift+RMB (Right Mouse Button) while the CppExplorer menu is open to begin Inspect-Under-Mouse.
|
* Press Shift+RMB (Right Mouse Button) while the CppExplorer menu is open to begin Inspect-Under-Mouse.
|
||||||
@ -98,10 +92,21 @@ CppExplorer can force the mouse to be visible and unlocked when the menu is open
|
|||||||
* For Hellpoint, use [HPExplorerMouseControl](https://github.com/sinai-dev/Hellpoint-Mods/tree/master/HPExplorerMouseControl/HPExplorerMouseControl)
|
* For Hellpoint, use [HPExplorerMouseControl](https://github.com/sinai-dev/Hellpoint-Mods/tree/master/HPExplorerMouseControl/HPExplorerMouseControl)
|
||||||
* You can create your own plugin using one of the two plugins above as an example. Usually only a few simple Harmony patches are needed to fix the problem.
|
* You can create your own plugin using one of the two plugins above as an example. Usually only a few simple Harmony patches are needed to fix the problem.
|
||||||
|
|
||||||
|
## Building
|
||||||
|
|
||||||
|
If you'd like to build this yourself, everything you need (other than MelonLoader) is included with this repository, there is no need for recursive cloning etc.
|
||||||
|
|
||||||
|
1. Install MelonLoader for your game.
|
||||||
|
2. Open the `src\CppExplorer.csproj` file in a text editor.
|
||||||
|
3. Scroll down until you see the `<ItemGroup>` containing the References.
|
||||||
|
4. Fix all of the paths in the `..\Steam\` directory for your game (use the full path if you need to).
|
||||||
|
5. Open the `src\CppExplorer.sln` project and build it.
|
||||||
|
6. The dll is built to the `Release\` folder in the root of the repository.
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
|
|
||||||
Written by Sinai.
|
Written by Sinai.
|
||||||
|
|
||||||
Thanks to:
|
Thanks to:
|
||||||
* [ManlyMarco](https://github.com/ManlyMarco) for their [Runtime Unity Editor](https://github.com/ManlyMarco/RuntimeUnityEditor), which I used for the REPL Console and the "Find instances" snippet, and the UI style.
|
* [ManlyMarco](https://github.com/ManlyMarco) for their [Runtime Unity Editor](https://github.com/ManlyMarco/RuntimeUnityEditor), which I used for the REPL Console and the "Find instances" snippet, and the UI style.
|
||||||
* [denikson](https://github.com/denikson) for [mcs-unity](https://github.com/denikson/mcs-unity). I commented out the `SkipVisibilityExt` constructor in `mcs.dll` since it was causing an exception with the Hook it attempted.
|
* [denikson](https://github.com/denikson) for [mcs-unity](https://github.com/denikson/mcs-unity). I commented out the `SkipVisibilityExt` constructor since it was causing an exception with the Hook it attempted.
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using MelonLoader;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace Explorer
|
|
||||||
{
|
|
||||||
public class CacheDictionary : CacheObjectBase
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
public override void Init()
|
|
||||||
{
|
|
||||||
//base.Init();
|
|
||||||
|
|
||||||
Value = "Unsupported";
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void UpdateValue()
|
|
||||||
{
|
|
||||||
//base.UpdateValue();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void DrawValue(Rect window, float width)
|
|
||||||
{
|
|
||||||
GUILayout.Label("<color=red>Dictionary (unsupported)</color>", null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,223 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Reflection;
|
|
||||||
using UnityEngine;
|
|
||||||
using MelonLoader;
|
|
||||||
|
|
||||||
namespace Explorer
|
|
||||||
{
|
|
||||||
public class CacheMethod : CacheObjectBase
|
|
||||||
{
|
|
||||||
private bool m_evaluated = false;
|
|
||||||
private CacheObjectBase m_cachedReturnValue;
|
|
||||||
|
|
||||||
private bool m_isEvaluating;
|
|
||||||
private ParameterInfo[] m_arguments;
|
|
||||||
private string[] m_argumentInput;
|
|
||||||
|
|
||||||
public bool HasParameters
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (m_hasParams == null)
|
|
||||||
{
|
|
||||||
m_hasParams = (MemInfo as MethodInfo).GetParameters().Length > 0;
|
|
||||||
}
|
|
||||||
return (bool)m_hasParams;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private bool? m_hasParams;
|
|
||||||
|
|
||||||
public static bool CanEvaluate(MethodInfo mi)
|
|
||||||
{
|
|
||||||
// generic type args not supported yet
|
|
||||||
if (mi.GetGenericArguments().Length > 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// only primitive and string args supported
|
|
||||||
foreach (var param in mi.GetParameters())
|
|
||||||
{
|
|
||||||
if (!param.ParameterType.IsPrimitive && param.ParameterType != typeof(string))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Init()
|
|
||||||
{
|
|
||||||
base.Init();
|
|
||||||
|
|
||||||
var mi = MemInfo as MethodInfo;
|
|
||||||
|
|
||||||
m_arguments = mi.GetParameters();
|
|
||||||
m_argumentInput = new string[m_arguments.Length];
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void UpdateValue()
|
|
||||||
{
|
|
||||||
//base.UpdateValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void DrawValue(Rect window, float width)
|
|
||||||
{
|
|
||||||
GUILayout.BeginVertical(null);
|
|
||||||
|
|
||||||
string evaluateLabel = "<color=lime>Evaluate</color>";
|
|
||||||
if (HasParameters)
|
|
||||||
{
|
|
||||||
if (m_isEvaluating)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < m_arguments.Length; i++)
|
|
||||||
{
|
|
||||||
var name = m_arguments[i].Name;
|
|
||||||
var input = m_argumentInput[i];
|
|
||||||
var type = m_arguments[i].ParameterType.Name;
|
|
||||||
|
|
||||||
GUILayout.BeginHorizontal(null);
|
|
||||||
m_argumentInput[i] = GUILayout.TextField(input, new GUILayoutOption[] { GUILayout.Width(150) });
|
|
||||||
GUILayout.Label(i + ": <color=cyan>" + name + "</color> <color=yellow>(" + type + ")</color>", null);
|
|
||||||
|
|
||||||
GUILayout.EndHorizontal();
|
|
||||||
}
|
|
||||||
|
|
||||||
GUILayout.BeginHorizontal(null);
|
|
||||||
if (GUILayout.Button(evaluateLabel, new GUILayoutOption[] { GUILayout.Width(70) }))
|
|
||||||
{
|
|
||||||
Evaluate();
|
|
||||||
m_isEvaluating = false;
|
|
||||||
}
|
|
||||||
if (GUILayout.Button("Cancel", new GUILayoutOption[] { GUILayout.Width(70) }))
|
|
||||||
{
|
|
||||||
m_isEvaluating = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GUILayout.BeginHorizontal(null);
|
|
||||||
if (GUILayout.Button($"Evaluate ({m_arguments.Length} params)", new GUILayoutOption[] { GUILayout.Width(150) }))
|
|
||||||
{
|
|
||||||
m_isEvaluating = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GUILayout.BeginHorizontal(null);
|
|
||||||
if (GUILayout.Button(evaluateLabel, new GUILayoutOption[] { GUILayout.Width(70) }))
|
|
||||||
{
|
|
||||||
Evaluate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GUILayout.EndHorizontal();
|
|
||||||
|
|
||||||
GUILayout.BeginHorizontal(null);
|
|
||||||
if (m_evaluated)
|
|
||||||
{
|
|
||||||
if (m_cachedReturnValue != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
m_cachedReturnValue.DrawValue(window, width);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
MelonLogger.Log("Exception drawing m_cachedReturnValue!");
|
|
||||||
MelonLogger.Log(e.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GUILayout.Label($"null (<color=yellow>{ValueTypeName}</color>)", null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GUILayout.Label($"<color=grey><i>Not yet evaluated</i></color> (<color=yellow>{ValueTypeName}</color>)", null);
|
|
||||||
}
|
|
||||||
GUILayout.EndHorizontal();
|
|
||||||
|
|
||||||
GUILayout.EndVertical();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Evaluate()
|
|
||||||
{
|
|
||||||
var mi = MemInfo as MethodInfo;
|
|
||||||
|
|
||||||
object ret = null;
|
|
||||||
|
|
||||||
if (!HasParameters)
|
|
||||||
{
|
|
||||||
ret = mi.Invoke(mi.IsStatic ? null : DeclaringInstance, new object[0]);
|
|
||||||
m_evaluated = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var arguments = new List<object>();
|
|
||||||
for (int i = 0; i < m_arguments.Length; i++)
|
|
||||||
{
|
|
||||||
var input = m_argumentInput[i];
|
|
||||||
var type = m_arguments[i].ParameterType;
|
|
||||||
|
|
||||||
if (type == typeof(string))
|
|
||||||
{
|
|
||||||
arguments.Add(input);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (type.GetMethod("Parse", new Type[] { typeof(string) }).Invoke(null, new object[] { input }) is object parsed)
|
|
||||||
{
|
|
||||||
arguments.Add(parsed);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new Exception();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
MelonLogger.Log($"Unable to parse '{input}' to type '{type.Name}'");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (arguments.Count == m_arguments.Length)
|
|
||||||
{
|
|
||||||
ret = mi.Invoke(mi.IsStatic ? null : DeclaringInstance, arguments.ToArray());
|
|
||||||
m_evaluated = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MelonLogger.Log($"Did not invoke because {m_arguments.Length - arguments.Count} arguments could not be parsed!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret != null)
|
|
||||||
{
|
|
||||||
m_cachedReturnValue = GetCacheObject(ret);
|
|
||||||
if (m_cachedReturnValue is CacheList cacheList)
|
|
||||||
{
|
|
||||||
cacheList.WhiteSpace = 0f;
|
|
||||||
cacheList.ButtonWidthOffset += 70f;
|
|
||||||
}
|
|
||||||
m_cachedReturnValue.UpdateValue();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_cachedReturnValue = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -14,15 +14,19 @@ namespace Explorer
|
|||||||
{
|
{
|
||||||
public object Value;
|
public object Value;
|
||||||
public string ValueTypeName;
|
public string ValueTypeName;
|
||||||
|
public Type ValueType;
|
||||||
|
|
||||||
// Reflection Inspector only
|
|
||||||
public MemberInfo MemInfo { get; set; }
|
public MemberInfo MemInfo { get; set; }
|
||||||
public Type DeclaringType { get; set; }
|
public Type DeclaringType { get; set; }
|
||||||
public object DeclaringInstance { get; set; }
|
public object DeclaringInstance { get; set; }
|
||||||
public string ReflectionException { get; set; }
|
|
||||||
|
|
||||||
public int PropertyIndex { get; private set; }
|
public bool HasParameters => m_arguments != null && m_arguments.Length > 0;
|
||||||
private string m_propertyIndexInput = "0";
|
public bool m_evaluated = false;
|
||||||
|
public bool m_isEvaluating;
|
||||||
|
public ParameterInfo[] m_arguments = new ParameterInfo[0];
|
||||||
|
public string[] m_argumentInput = new string[0];
|
||||||
|
|
||||||
|
public string ReflectionException { get; set; }
|
||||||
|
|
||||||
public string RichTextName => m_richTextName ?? GetRichTextName();
|
public string RichTextName => m_richTextName ?? GetRichTextName();
|
||||||
private string m_richTextName;
|
private string m_richTextName;
|
||||||
@ -43,7 +47,6 @@ namespace Explorer
|
|||||||
// ===== Abstract/Virtual Methods ===== //
|
// ===== Abstract/Virtual Methods ===== //
|
||||||
|
|
||||||
public virtual void Init() { }
|
public virtual void Init() { }
|
||||||
|
|
||||||
public abstract void DrawValue(Rect window, float width);
|
public abstract void DrawValue(Rect window, float width);
|
||||||
|
|
||||||
// ===== Static Methods ===== //
|
// ===== Static Methods ===== //
|
||||||
@ -79,11 +82,7 @@ namespace Explorer
|
|||||||
{
|
{
|
||||||
Type type = null;
|
Type type = null;
|
||||||
|
|
||||||
if (obj != null)
|
if (memberInfo != null)
|
||||||
{
|
|
||||||
type = ReflectionHelpers.GetActualType(obj);
|
|
||||||
}
|
|
||||||
else if (memberInfo != null)
|
|
||||||
{
|
{
|
||||||
if (memberInfo is FieldInfo fi)
|
if (memberInfo is FieldInfo fi)
|
||||||
{
|
{
|
||||||
@ -98,6 +97,10 @@ namespace Explorer
|
|||||||
type = mi.ReturnType;
|
type = mi.ReturnType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (obj != null)
|
||||||
|
{
|
||||||
|
type = ReflectionHelpers.GetActualType(obj);
|
||||||
|
}
|
||||||
|
|
||||||
if (type == null)
|
if (type == null)
|
||||||
{
|
{
|
||||||
@ -114,7 +117,21 @@ namespace Explorer
|
|||||||
{
|
{
|
||||||
CacheObjectBase holder;
|
CacheObjectBase holder;
|
||||||
|
|
||||||
if (memberInfo is MethodInfo mi)
|
var pi = memberInfo as PropertyInfo;
|
||||||
|
var mi = memberInfo as MethodInfo;
|
||||||
|
|
||||||
|
// if PropertyInfo, check if can process args
|
||||||
|
if (pi != null && !CanProcessArgs(pi.GetIndexParameters()))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is pretty ugly, could probably make a cleaner implementation.
|
||||||
|
// However, the only cleaner ways I can think of are slower and probably not worth it.
|
||||||
|
|
||||||
|
// Note: the order is somewhat important.
|
||||||
|
|
||||||
|
if (mi != null)
|
||||||
{
|
{
|
||||||
if (CacheMethod.CanEvaluate(mi))
|
if (CacheMethod.CanEvaluate(mi))
|
||||||
{
|
{
|
||||||
@ -137,20 +154,38 @@ namespace Explorer
|
|||||||
{
|
{
|
||||||
holder = new CacheEnum();
|
holder = new CacheEnum();
|
||||||
}
|
}
|
||||||
else if (ReflectionHelpers.IsArray(valueType) || ReflectionHelpers.IsList(valueType))
|
else if (valueType == typeof(Vector2) || valueType == typeof(Vector3) || valueType == typeof(Vector4))
|
||||||
{
|
{
|
||||||
holder = new CacheList();
|
holder = new CacheVector();
|
||||||
}
|
}
|
||||||
|
else if (valueType == typeof(Quaternion))
|
||||||
|
{
|
||||||
|
holder = new CacheQuaternion();
|
||||||
|
}
|
||||||
|
else if (valueType == typeof(Color))
|
||||||
|
{
|
||||||
|
holder = new CacheColor();
|
||||||
|
}
|
||||||
|
else if (valueType == typeof(Rect))
|
||||||
|
{
|
||||||
|
holder = new CacheRect();
|
||||||
|
}
|
||||||
|
// must check this before IsEnumerable
|
||||||
else if (ReflectionHelpers.IsDictionary(valueType))
|
else if (ReflectionHelpers.IsDictionary(valueType))
|
||||||
{
|
{
|
||||||
holder = new CacheDictionary();
|
holder = new CacheDictionary();
|
||||||
}
|
}
|
||||||
|
else if (ReflectionHelpers.IsEnumerable(valueType) || ReflectionHelpers.IsCppList(valueType))
|
||||||
|
{
|
||||||
|
holder = new CacheList();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
holder = new CacheOther();
|
holder = new CacheOther();
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.Value = obj;
|
holder.Value = obj;
|
||||||
|
holder.ValueType = valueType;
|
||||||
holder.ValueTypeName = valueType.FullName;
|
holder.ValueTypeName = valueType.FullName;
|
||||||
|
|
||||||
if (memberInfo != null)
|
if (memberInfo != null)
|
||||||
@ -158,7 +193,21 @@ namespace Explorer
|
|||||||
holder.MemInfo = memberInfo;
|
holder.MemInfo = memberInfo;
|
||||||
holder.DeclaringType = memberInfo.DeclaringType;
|
holder.DeclaringType = memberInfo.DeclaringType;
|
||||||
holder.DeclaringInstance = declaringInstance;
|
holder.DeclaringInstance = declaringInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pi != null)
|
||||||
|
{
|
||||||
|
holder.m_arguments = pi.GetIndexParameters();
|
||||||
|
}
|
||||||
|
else if (mi != null)
|
||||||
|
{
|
||||||
|
holder.m_arguments = mi.GetParameters();
|
||||||
|
}
|
||||||
|
|
||||||
|
holder.m_argumentInput = new string[holder.m_arguments.Length];
|
||||||
|
|
||||||
|
if (!holder.HasParameters)
|
||||||
|
{
|
||||||
holder.UpdateValue();
|
holder.UpdateValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,11 +216,57 @@ namespace Explorer
|
|||||||
return holder;
|
return holder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool CanProcessArgs(ParameterInfo[] parameters)
|
||||||
|
{
|
||||||
|
foreach (var param in parameters)
|
||||||
|
{
|
||||||
|
if (!param.ParameterType.IsPrimitive && param.ParameterType != typeof(string))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// ======== Instance Methods =========
|
// ======== Instance Methods =========
|
||||||
|
|
||||||
|
public object[] ParseArguments()
|
||||||
|
{
|
||||||
|
var parsedArgs = new List<object>();
|
||||||
|
for (int i = 0; i < m_arguments.Length; i++)
|
||||||
|
{
|
||||||
|
var input = m_argumentInput[i];
|
||||||
|
var type = m_arguments[i].ParameterType;
|
||||||
|
|
||||||
|
if (type == typeof(string))
|
||||||
|
{
|
||||||
|
parsedArgs.Add(input);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
parsedArgs.Add(type.GetMethod("Parse", new Type[] { typeof(string) }).Invoke(null, new object[] { input }));
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
//MelonLogger.Log($"Unable to parse '{input}' to type '{type.Name}'");
|
||||||
|
|
||||||
|
// try add a null arg i guess
|
||||||
|
parsedArgs.Add(null);
|
||||||
|
|
||||||
|
//break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return parsedArgs.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void UpdateValue()
|
public virtual void UpdateValue()
|
||||||
{
|
{
|
||||||
if (MemInfo == null || !string.IsNullOrEmpty(ReflectionException))
|
if (MemInfo == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -186,13 +281,11 @@ namespace Explorer
|
|||||||
else if (MemInfo.MemberType == MemberTypes.Property)
|
else if (MemInfo.MemberType == MemberTypes.Property)
|
||||||
{
|
{
|
||||||
var pi = MemInfo as PropertyInfo;
|
var pi = MemInfo as PropertyInfo;
|
||||||
bool isStatic = pi.GetAccessors()[0].IsStatic;
|
var target = pi.GetAccessors()[0].IsStatic ? null : DeclaringInstance;
|
||||||
var target = isStatic ? null : DeclaringInstance;
|
|
||||||
|
|
||||||
if (pi.GetIndexParameters().Length > 0)
|
if (HasParameters)
|
||||||
{
|
{
|
||||||
var indexes = new object[] { PropertyIndex };
|
Value = pi.GetValue(target, ParseArguments());
|
||||||
Value = pi.GetValue(target, indexes);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -201,6 +294,8 @@ namespace Explorer
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReflectionException = null;
|
ReflectionException = null;
|
||||||
|
m_evaluated = true;
|
||||||
|
m_isEvaluating = false;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -221,10 +316,9 @@ namespace Explorer
|
|||||||
{
|
{
|
||||||
var pi = MemInfo as PropertyInfo;
|
var pi = MemInfo as PropertyInfo;
|
||||||
|
|
||||||
if (pi.GetIndexParameters().Length > 0)
|
if (HasParameters)
|
||||||
{
|
{
|
||||||
var indexes = new object[] { PropertyIndex };
|
pi.SetValue(pi.GetAccessors()[0].IsStatic ? null : DeclaringInstance, Value, ParseArguments());
|
||||||
pi.SetValue(pi.GetAccessors()[0].IsStatic ? null : DeclaringInstance, Value, indexes);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -241,6 +335,7 @@ namespace Explorer
|
|||||||
// ========= Instance Gui Draw ==========
|
// ========= Instance Gui Draw ==========
|
||||||
|
|
||||||
public const float MAX_LABEL_WIDTH = 400f;
|
public const float MAX_LABEL_WIDTH = 400f;
|
||||||
|
public const string EVALUATE_LABEL = "<color=lime>Evaluate</color>";
|
||||||
|
|
||||||
public static void ClampLabelWidth(Rect window, ref float labelWidth)
|
public static void ClampLabelWidth(Rect window, ref float labelWidth)
|
||||||
{
|
{
|
||||||
@ -259,19 +354,86 @@ namespace Explorer
|
|||||||
|
|
||||||
if (MemInfo != null)
|
if (MemInfo != null)
|
||||||
{
|
{
|
||||||
var name = RichTextName;
|
GUILayout.Label(RichTextName, new GUILayoutOption[] { GUILayout.Width(labelWidth) });
|
||||||
if (MemInfo is PropertyInfo pi && pi.GetIndexParameters().Length > 0)
|
|
||||||
{
|
|
||||||
name += $"[{PropertyIndex}]";
|
|
||||||
}
|
|
||||||
|
|
||||||
GUILayout.Label(name, new GUILayoutOption[] { GUILayout.Width(labelWidth) });
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GUILayout.Space(labelWidth);
|
GUILayout.Space(labelWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var cm = this as CacheMethod;
|
||||||
|
|
||||||
|
if (HasParameters)
|
||||||
|
{
|
||||||
|
GUILayout.BeginVertical(null);
|
||||||
|
|
||||||
|
if (m_isEvaluating)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < m_arguments.Length; i++)
|
||||||
|
{
|
||||||
|
var name = m_arguments[i].Name;
|
||||||
|
var input = m_argumentInput[i];
|
||||||
|
var type = m_arguments[i].ParameterType.Name;
|
||||||
|
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
GUILayout.Label(i.ToString(), new GUILayoutOption[] { GUILayout.Width(30) });
|
||||||
|
m_argumentInput[i] = GUILayout.TextField(input, new GUILayoutOption[] { GUILayout.Width(150) });
|
||||||
|
GUILayout.Label("<color=#2df7b2>" + type + "</color> <color=cyan>" + name + "</color>", null);
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
}
|
||||||
|
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
if (cm != null)
|
||||||
|
{
|
||||||
|
if (GUILayout.Button(EVALUATE_LABEL, new GUILayoutOption[] { GUILayout.Width(70) }))
|
||||||
|
{
|
||||||
|
cm.Evaluate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (GUILayout.Button(EVALUATE_LABEL, new GUILayoutOption[] { GUILayout.Width(70) }))
|
||||||
|
{
|
||||||
|
UpdateValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GUILayout.Button("Cancel", new GUILayoutOption[] { GUILayout.Width(70) }))
|
||||||
|
{
|
||||||
|
m_isEvaluating = false;
|
||||||
|
}
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (GUILayout.Button($"Evaluate ({m_arguments.Length} params)", new GUILayoutOption[] { GUILayout.Width(150) }))
|
||||||
|
{
|
||||||
|
m_isEvaluating = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GUILayout.EndVertical();
|
||||||
|
|
||||||
|
// new line and space
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
GUILayout.Space(labelWidth);
|
||||||
|
}
|
||||||
|
else if (cm != null)
|
||||||
|
{
|
||||||
|
//GUILayout.BeginHorizontal(null);
|
||||||
|
|
||||||
|
if (GUILayout.Button(EVALUATE_LABEL, new GUILayoutOption[] { GUILayout.Width(70) }))
|
||||||
|
{
|
||||||
|
cm.Evaluate();
|
||||||
|
}
|
||||||
|
|
||||||
|
// new line and space
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
GUILayout.Space(labelWidth);
|
||||||
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(ReflectionException))
|
if (!string.IsNullOrEmpty(ReflectionException))
|
||||||
{
|
{
|
||||||
GUILayout.Label("<color=red>Reflection failed!</color> (" + ReflectionException + ")", null);
|
GUILayout.Label("<color=red>Reflection failed!</color> (" + ReflectionException + ")", null);
|
||||||
@ -282,30 +444,6 @@ namespace Explorer
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (MemInfo is PropertyInfo pi && pi.GetIndexParameters().Length > 0)
|
|
||||||
{
|
|
||||||
GUILayout.Label("index:", new GUILayoutOption[] { GUILayout.Width(50) });
|
|
||||||
|
|
||||||
m_propertyIndexInput = GUILayout.TextField(m_propertyIndexInput, new GUILayoutOption[] { GUILayout.Width(100) });
|
|
||||||
if (GUILayout.Button("Set", new GUILayoutOption[] { GUILayout.Width(60) }))
|
|
||||||
{
|
|
||||||
if (int.TryParse(m_propertyIndexInput, out int i))
|
|
||||||
{
|
|
||||||
PropertyIndex = i;
|
|
||||||
UpdateValue();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MelonLogger.Log($"Could not parse '{m_propertyIndexInput}' to an int!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// new line and space
|
|
||||||
GUILayout.EndHorizontal();
|
|
||||||
GUILayout.BeginHorizontal(null);
|
|
||||||
GUILayout.Space(labelWidth);
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawValue(window, window.width - labelWidth - 90);
|
DrawValue(window, window.width - labelWidth - 90);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -325,15 +463,15 @@ namespace Explorer
|
|||||||
|
|
||||||
m_richTextName = $"<color=#2df7b2>{MemInfo.DeclaringType.Name}</color>.<color={memberColor}>{MemInfo.Name}</color>";
|
m_richTextName = $"<color=#2df7b2>{MemInfo.DeclaringType.Name}</color>.<color={memberColor}>{MemInfo.Name}</color>";
|
||||||
|
|
||||||
if (MemInfo is MethodInfo mi)
|
if (m_arguments.Length > 0)
|
||||||
{
|
{
|
||||||
m_richTextName += "(";
|
m_richTextName += "(";
|
||||||
var _params = "";
|
var _params = "";
|
||||||
foreach (var param in mi.GetParameters())
|
foreach (var param in m_arguments)
|
||||||
{
|
{
|
||||||
if (_params != "") _params += ", ";
|
if (_params != "") _params += ", ";
|
||||||
|
|
||||||
_params += $"<color=#a6e9e9>{param.Name}</color>";
|
_params += $"<color=#2df7b2>{param.ParameterType.Name}</color> <color=#a6e9e9>{param.Name}</color>";
|
||||||
}
|
}
|
||||||
m_richTextName += _params;
|
m_richTextName += _params;
|
||||||
m_richTextName += ")";
|
m_richTextName += ")";
|
||||||
|
@ -1,181 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Reflection;
|
|
||||||
using MelonLoader;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace Explorer
|
|
||||||
{
|
|
||||||
public class CachePrimitive : CacheObjectBase
|
|
||||||
{
|
|
||||||
public enum PrimitiveTypes
|
|
||||||
{
|
|
||||||
Bool,
|
|
||||||
Double,
|
|
||||||
Float,
|
|
||||||
Int,
|
|
||||||
String,
|
|
||||||
Char
|
|
||||||
}
|
|
||||||
|
|
||||||
private string m_valueToString;
|
|
||||||
|
|
||||||
public PrimitiveTypes PrimitiveType;
|
|
||||||
|
|
||||||
public MethodInfo ParseMethod
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (m_parseMethod == null)
|
|
||||||
{
|
|
||||||
m_parseMethod = Value.GetType().GetMethod("Parse", new Type[] { typeof(string) });
|
|
||||||
}
|
|
||||||
return m_parseMethod;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private MethodInfo m_parseMethod;
|
|
||||||
|
|
||||||
public override void Init()
|
|
||||||
{
|
|
||||||
if (Value == null)
|
|
||||||
{
|
|
||||||
// this must mean it is a string. No other primitive type should be nullable.
|
|
||||||
PrimitiveType = PrimitiveTypes.String;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_valueToString = Value.ToString();
|
|
||||||
var type = Value.GetType();
|
|
||||||
|
|
||||||
if (type == typeof(bool))
|
|
||||||
{
|
|
||||||
PrimitiveType = PrimitiveTypes.Bool;
|
|
||||||
}
|
|
||||||
else if (type == typeof(double))
|
|
||||||
{
|
|
||||||
PrimitiveType = PrimitiveTypes.Double;
|
|
||||||
}
|
|
||||||
else if (type == typeof(float))
|
|
||||||
{
|
|
||||||
PrimitiveType = PrimitiveTypes.Float;
|
|
||||||
}
|
|
||||||
else if (IsInteger(type))
|
|
||||||
{
|
|
||||||
PrimitiveType = PrimitiveTypes.Int;
|
|
||||||
}
|
|
||||||
else if (type == typeof(char))
|
|
||||||
{
|
|
||||||
PrimitiveType = PrimitiveTypes.Char;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PrimitiveType = PrimitiveTypes.String;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static bool IsInteger(Type type)
|
|
||||||
{
|
|
||||||
// For our purposes, all types of int can be treated the same, including IntPtr.
|
|
||||||
return _integerTypes.Contains(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static readonly HashSet<Type> _integerTypes = new HashSet<Type>
|
|
||||||
{
|
|
||||||
typeof(int),
|
|
||||||
typeof(uint),
|
|
||||||
typeof(short),
|
|
||||||
typeof(ushort),
|
|
||||||
typeof(long),
|
|
||||||
typeof(ulong),
|
|
||||||
typeof(byte),
|
|
||||||
typeof(sbyte),
|
|
||||||
typeof(IntPtr)
|
|
||||||
};
|
|
||||||
|
|
||||||
public override void UpdateValue()
|
|
||||||
{
|
|
||||||
base.UpdateValue();
|
|
||||||
|
|
||||||
m_valueToString = Value?.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void DrawValue(Rect window, float width)
|
|
||||||
{
|
|
||||||
if (PrimitiveType == PrimitiveTypes.Bool)
|
|
||||||
{
|
|
||||||
var b = (bool)Value;
|
|
||||||
var color = $"<color={(b ? "lime>" : "red>")}";
|
|
||||||
var label = $"{color}{b}</color>";
|
|
||||||
|
|
||||||
if (CanWrite)
|
|
||||||
{
|
|
||||||
b = GUILayout.Toggle(b, label, null);
|
|
||||||
if (b != (bool)Value)
|
|
||||||
{
|
|
||||||
SetValueFromInput(b.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GUILayout.Label(label, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GUILayout.Label("<color=yellow><i>" + PrimitiveType + "</i></color>", new GUILayoutOption[] { GUILayout.Width(50) });
|
|
||||||
|
|
||||||
int dynSize = 25 + (m_valueToString.Length * 15);
|
|
||||||
var maxwidth = window.width - 300f;
|
|
||||||
if (CanWrite) maxwidth -= 60;
|
|
||||||
|
|
||||||
if (dynSize > maxwidth)
|
|
||||||
{
|
|
||||||
m_valueToString = GUILayout.TextArea(m_valueToString, new GUILayoutOption[] { GUILayout.MaxWidth(maxwidth) });
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_valueToString = GUILayout.TextField(m_valueToString, new GUILayoutOption[] { GUILayout.MaxWidth(dynSize) });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CanWrite)
|
|
||||||
{
|
|
||||||
if (GUILayout.Button("<color=#00FF00>Apply</color>", new GUILayoutOption[] { GUILayout.Width(60) }))
|
|
||||||
{
|
|
||||||
SetValueFromInput(m_valueToString);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GUILayout.Space(5);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetValueFromInput(string value)
|
|
||||||
{
|
|
||||||
if (MemInfo == null)
|
|
||||||
{
|
|
||||||
MelonLogger.Log("Trying to SetValue but the MemberInfo is null!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PrimitiveType == PrimitiveTypes.String)
|
|
||||||
{
|
|
||||||
Value = value;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var val = ParseMethod.Invoke(null, new object[] { value });
|
|
||||||
Value = val;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
MelonLogger.Log("Exception parsing value: " + e.GetType() + ", " + e.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SetValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
304
src/CachedObjects/Object/CacheDictionary.cs
Normal file
304
src/CachedObjects/Object/CacheDictionary.cs
Normal file
@ -0,0 +1,304 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using MelonLoader;
|
||||||
|
using UnityEngine;
|
||||||
|
using System.Reflection;
|
||||||
|
using UnhollowerBaseLib;
|
||||||
|
|
||||||
|
namespace Explorer
|
||||||
|
{
|
||||||
|
public class CacheDictionary : CacheObjectBase, IExpandHeight
|
||||||
|
{
|
||||||
|
public bool IsExpanded { get; set; }
|
||||||
|
public float WhiteSpace { get; set; } = 215f;
|
||||||
|
public float ButtonWidthOffset { get; set; } = 350f;
|
||||||
|
|
||||||
|
public PageHelper Pages = new PageHelper();
|
||||||
|
|
||||||
|
private CacheObjectBase[] m_cachedKeys;
|
||||||
|
private CacheObjectBase[] m_cachedValues;
|
||||||
|
|
||||||
|
public Type TypeOfKeys
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (m_keysType == null) GetGenericArguments();
|
||||||
|
return m_keysType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private Type m_keysType;
|
||||||
|
|
||||||
|
public Type TypeOfValues
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (m_valuesType == null) GetGenericArguments();
|
||||||
|
return m_valuesType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private Type m_valuesType;
|
||||||
|
|
||||||
|
public IDictionary IDict
|
||||||
|
{
|
||||||
|
get => m_iDictionary ?? (m_iDictionary = Value as IDictionary) ?? Il2CppDictionaryToMono();
|
||||||
|
set => m_iDictionary = value;
|
||||||
|
}
|
||||||
|
private IDictionary m_iDictionary;
|
||||||
|
|
||||||
|
// ========== Methods ==========
|
||||||
|
|
||||||
|
// This is a bit janky due to Il2Cpp Dictionary not implementing IDictionary.
|
||||||
|
private IDictionary Il2CppDictionaryToMono()
|
||||||
|
{
|
||||||
|
// note: "ValueType" is the Dictionary itself, TypeOfValues is the 'Dictionary.Values' type.
|
||||||
|
|
||||||
|
// get keys and values
|
||||||
|
var keys = ValueType.GetProperty("Keys") .GetValue(Value);
|
||||||
|
var values = ValueType.GetProperty("Values").GetValue(Value);
|
||||||
|
|
||||||
|
// create lists to hold them
|
||||||
|
var keyList = new List<object>();
|
||||||
|
var valueList = new List<object>();
|
||||||
|
|
||||||
|
// store entries with reflection
|
||||||
|
EnumerateWithReflection(keys, keyList);
|
||||||
|
EnumerateWithReflection(values, valueList);
|
||||||
|
|
||||||
|
// make actual mono dictionary
|
||||||
|
var dict = (IDictionary)Activator.CreateInstance(typeof(Dictionary<,>)
|
||||||
|
.MakeGenericType(TypeOfKeys, TypeOfValues));
|
||||||
|
|
||||||
|
// finally iterate into dictionary
|
||||||
|
for (int i = 0; i < keyList.Count; i++)
|
||||||
|
{
|
||||||
|
dict.Add(keyList[i], valueList[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dict;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EnumerateWithReflection(object collection, List<object> list)
|
||||||
|
{
|
||||||
|
// invoke GetEnumerator
|
||||||
|
var enumerator = collection.GetType().GetMethod("GetEnumerator").Invoke(collection, null);
|
||||||
|
// get the type of it
|
||||||
|
var enumeratorType = enumerator.GetType();
|
||||||
|
// reflect MoveNext and Current
|
||||||
|
var moveNext = enumeratorType.GetMethod("MoveNext");
|
||||||
|
var current = enumeratorType.GetProperty("Current");
|
||||||
|
// iterate
|
||||||
|
while ((bool)moveNext.Invoke(enumerator, null))
|
||||||
|
{
|
||||||
|
list.Add(current.GetValue(enumerator));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GetGenericArguments()
|
||||||
|
{
|
||||||
|
if (this.MemInfo != null)
|
||||||
|
{
|
||||||
|
Type memberType = null;
|
||||||
|
switch (this.MemInfo.MemberType)
|
||||||
|
{
|
||||||
|
case MemberTypes.Field:
|
||||||
|
memberType = (MemInfo as FieldInfo).FieldType;
|
||||||
|
break;
|
||||||
|
case MemberTypes.Property:
|
||||||
|
memberType = (MemInfo as PropertyInfo).PropertyType;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (memberType != null && memberType.IsGenericType)
|
||||||
|
{
|
||||||
|
m_keysType = memberType.GetGenericArguments()[0];
|
||||||
|
m_valuesType = memberType.GetGenericArguments()[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (Value != null)
|
||||||
|
{
|
||||||
|
var type = Value.GetType();
|
||||||
|
if (type.IsGenericType)
|
||||||
|
{
|
||||||
|
m_keysType = type.GetGenericArguments()[0];
|
||||||
|
m_valuesType = type.GetGenericArguments()[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void UpdateValue()
|
||||||
|
{
|
||||||
|
// first make sure we won't run into a TypeInitializationException.
|
||||||
|
if (!EnsureDictionaryIsSupported())
|
||||||
|
{
|
||||||
|
ReflectionException = "Dictionary Type not supported with Reflection!";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
base.UpdateValue();
|
||||||
|
|
||||||
|
// reset
|
||||||
|
IDict = null;
|
||||||
|
|
||||||
|
if (Value == null || IDict == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var keys = new List<CacheObjectBase>();
|
||||||
|
foreach (var key in IDict.Keys)
|
||||||
|
{
|
||||||
|
var cache = GetCacheObject(key, TypeOfKeys);
|
||||||
|
keys.Add(cache);
|
||||||
|
}
|
||||||
|
|
||||||
|
var values = new List<CacheObjectBase>();
|
||||||
|
foreach (var val in IDict.Values)
|
||||||
|
{
|
||||||
|
var cache = GetCacheObject(val, TypeOfValues);
|
||||||
|
values.Add(cache);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_cachedKeys = keys.ToArray();
|
||||||
|
m_cachedValues = values.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool EnsureDictionaryIsSupported()
|
||||||
|
{
|
||||||
|
if (typeof(IDictionary).IsAssignableFrom(ValueType))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Check(TypeOfKeys) && Check(TypeOfValues);
|
||||||
|
|
||||||
|
bool Check(Type type)
|
||||||
|
{
|
||||||
|
var ptr = (IntPtr)typeof(Il2CppClassPointerStore<>)
|
||||||
|
.MakeGenericType(type)
|
||||||
|
.GetField("NativeClassPtr")
|
||||||
|
.GetValue(null);
|
||||||
|
|
||||||
|
return Il2CppSystem.Type.internal_from_handle(IL2CPP.il2cpp_class_get_type(ptr)) is Il2CppSystem.Type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============= GUI Draw =============
|
||||||
|
|
||||||
|
public override void DrawValue(Rect window, float width)
|
||||||
|
{
|
||||||
|
if (m_cachedKeys == null || m_cachedValues == null)
|
||||||
|
{
|
||||||
|
GUILayout.Label("Cached keys or values is null!", null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float whitespace = WhiteSpace;
|
||||||
|
if (whitespace > 0)
|
||||||
|
{
|
||||||
|
ClampLabelWidth(window, ref whitespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
int count = m_cachedKeys.Length;
|
||||||
|
|
||||||
|
if (!IsExpanded)
|
||||||
|
{
|
||||||
|
if (GUILayout.Button("v", new GUILayoutOption[] { GUILayout.Width(25) }))
|
||||||
|
{
|
||||||
|
IsExpanded = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (GUILayout.Button("^", new GUILayoutOption[] { GUILayout.Width(25) }))
|
||||||
|
{
|
||||||
|
IsExpanded = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var negativeWhitespace = window.width - (whitespace + 100f);
|
||||||
|
|
||||||
|
GUI.skin.button.alignment = TextAnchor.MiddleLeft;
|
||||||
|
string btnLabel = $"<color=#2df7b2>[{count}] Dictionary<{TypeOfKeys.FullName}, {TypeOfValues.FullName}></color>";
|
||||||
|
if (GUILayout.Button(btnLabel, new GUILayoutOption[] { GUILayout.Width(negativeWhitespace) }))
|
||||||
|
{
|
||||||
|
WindowManager.InspectObject(Value, out bool _);
|
||||||
|
}
|
||||||
|
GUI.skin.button.alignment = TextAnchor.MiddleCenter;
|
||||||
|
|
||||||
|
GUILayout.Space(5);
|
||||||
|
|
||||||
|
if (IsExpanded)
|
||||||
|
{
|
||||||
|
Pages.ItemCount = count;
|
||||||
|
|
||||||
|
if (count > Pages.ItemsPerPage)
|
||||||
|
{
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
|
||||||
|
GUILayout.Space(whitespace);
|
||||||
|
|
||||||
|
Pages.CurrentPageLabel();
|
||||||
|
|
||||||
|
// prev/next page buttons
|
||||||
|
if (GUILayout.Button("< Prev", new GUILayoutOption[] { GUILayout.Width(60) }))
|
||||||
|
{
|
||||||
|
Pages.TurnPage(Turn.Left);
|
||||||
|
}
|
||||||
|
if (GUILayout.Button("Next >", new GUILayoutOption[] { GUILayout.Width(60) }))
|
||||||
|
{
|
||||||
|
Pages.TurnPage(Turn.Right);
|
||||||
|
}
|
||||||
|
|
||||||
|
Pages.DrawLimitInputArea();
|
||||||
|
|
||||||
|
GUILayout.Space(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
int offset = Pages.CalculateOffsetIndex();
|
||||||
|
|
||||||
|
for (int i = offset; i < offset + Pages.ItemsPerPage && i < count; i++)
|
||||||
|
{
|
||||||
|
var key = m_cachedKeys[i];
|
||||||
|
var val = m_cachedValues[i];
|
||||||
|
|
||||||
|
//collapsing the BeginHorizontal called from ReflectionWindow.WindowFunction or previous array entry
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
|
||||||
|
//GUILayout.Space(whitespace);
|
||||||
|
|
||||||
|
if (key == null || val == null)
|
||||||
|
{
|
||||||
|
GUILayout.Label($"[{i}] <i><color=grey>(null)</color></i>", null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GUI.skin.label.alignment = TextAnchor.MiddleCenter;
|
||||||
|
GUILayout.Label($"[{i}]", new GUILayoutOption[] { GUILayout.Width(30) });
|
||||||
|
|
||||||
|
GUILayout.Label("Key:", new GUILayoutOption[] { GUILayout.Width(40) });
|
||||||
|
key.DrawValue(window, (window.width / 2) - 30f);
|
||||||
|
|
||||||
|
GUILayout.Label("Value:", new GUILayoutOption[] { GUILayout.Width(40) });
|
||||||
|
val.DrawValue(window, (window.width / 2) - 30f);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
GUI.skin.label.alignment = TextAnchor.UpperLeft;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,13 +8,13 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace Explorer
|
namespace Explorer
|
||||||
{
|
{
|
||||||
public class CacheList : CacheObjectBase
|
public class CacheList : CacheObjectBase, IExpandHeight
|
||||||
{
|
{
|
||||||
public bool IsExpanded { get; set; }
|
public bool IsExpanded { get; set; }
|
||||||
public PageHelper Pages = new PageHelper();
|
public float WhiteSpace { get; set; } = 215f;
|
||||||
|
public float ButtonWidthOffset { get; set; } = 290f;
|
||||||
|
|
||||||
public float WhiteSpace = 215f;
|
public PageHelper Pages = new PageHelper();
|
||||||
public float ButtonWidthOffset = 290f;
|
|
||||||
|
|
||||||
private CacheObjectBase[] m_cachedEntries;
|
private CacheObjectBase[] m_cachedEntries;
|
||||||
|
|
||||||
@ -52,6 +52,7 @@ namespace Explorer
|
|||||||
{
|
{
|
||||||
get => GetItemProperty();
|
get => GetItemProperty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private PropertyInfo m_itemProperty;
|
private PropertyInfo m_itemProperty;
|
||||||
|
|
||||||
// ========== Methods ==========
|
// ========== Methods ==========
|
||||||
@ -244,6 +245,12 @@ namespace Explorer
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float whitespace = WhiteSpace;
|
||||||
|
if (whitespace > 0)
|
||||||
|
{
|
||||||
|
ClampLabelWidth(window, ref whitespace);
|
||||||
|
}
|
||||||
|
|
||||||
int count = m_cachedEntries.Length;
|
int count = m_cachedEntries.Length;
|
||||||
|
|
||||||
if (!IsExpanded)
|
if (!IsExpanded)
|
||||||
@ -261,9 +268,11 @@ namespace Explorer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var negativeWhitespace = window.width - (whitespace + 100f);
|
||||||
|
|
||||||
GUI.skin.button.alignment = TextAnchor.MiddleLeft;
|
GUI.skin.button.alignment = TextAnchor.MiddleLeft;
|
||||||
string btnLabel = "<color=yellow>[" + count + "] " + EntryType + "</color>";
|
string btnLabel = $"[{count}] <color=#2df7b2>{EntryType.FullName}</color>";
|
||||||
if (GUILayout.Button(btnLabel, new GUILayoutOption[] { GUILayout.MaxWidth(window.width - ButtonWidthOffset) }))
|
if (GUILayout.Button(btnLabel, new GUILayoutOption[] { GUILayout.MaxWidth(negativeWhitespace) }))
|
||||||
{
|
{
|
||||||
WindowManager.InspectObject(Value, out bool _);
|
WindowManager.InspectObject(Value, out bool _);
|
||||||
}
|
}
|
||||||
@ -273,12 +282,6 @@ namespace Explorer
|
|||||||
|
|
||||||
if (IsExpanded)
|
if (IsExpanded)
|
||||||
{
|
{
|
||||||
float whitespace = WhiteSpace;
|
|
||||||
if (whitespace > 0)
|
|
||||||
{
|
|
||||||
ClampLabelWidth(window, ref whitespace);
|
|
||||||
}
|
|
||||||
|
|
||||||
Pages.ItemCount = count;
|
Pages.ItemCount = count;
|
||||||
|
|
||||||
if (count > Pages.ItemsPerPage)
|
if (count > Pages.ItemsPerPage)
|
||||||
@ -305,12 +308,6 @@ namespace Explorer
|
|||||||
GUILayout.Space(5);
|
GUILayout.Space(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
//int offset = ArrayOffset * ArrayLimit;
|
|
||||||
//if (offset >= count)
|
|
||||||
//{
|
|
||||||
// offset = 0;
|
|
||||||
// ArrayOffset = 0;
|
|
||||||
//}
|
|
||||||
int offset = Pages.CalculateOffsetIndex();
|
int offset = Pages.CalculateOffsetIndex();
|
||||||
|
|
||||||
for (int i = offset; i < offset + Pages.ItemsPerPage && i < count; i++)
|
for (int i = offset; i < offset + Pages.ItemsPerPage && i < count; i++)
|
92
src/CachedObjects/Other/CacheMethod.cs
Normal file
92
src/CachedObjects/Other/CacheMethod.cs
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Reflection;
|
||||||
|
using UnityEngine;
|
||||||
|
using MelonLoader;
|
||||||
|
|
||||||
|
namespace Explorer
|
||||||
|
{
|
||||||
|
public class CacheMethod : CacheObjectBase
|
||||||
|
{
|
||||||
|
private CacheObjectBase m_cachedReturnValue;
|
||||||
|
|
||||||
|
public static bool CanEvaluate(MethodInfo mi)
|
||||||
|
{
|
||||||
|
// TODO generic args
|
||||||
|
if (mi.GetGenericArguments().Length > 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// primitive and string args supported
|
||||||
|
return CanProcessArgs(mi.GetParameters());
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void UpdateValue()
|
||||||
|
{
|
||||||
|
//base.UpdateValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Evaluate()
|
||||||
|
{
|
||||||
|
m_isEvaluating = false;
|
||||||
|
|
||||||
|
var mi = MemInfo as MethodInfo;
|
||||||
|
object ret = null;
|
||||||
|
|
||||||
|
if (!HasParameters)
|
||||||
|
{
|
||||||
|
ret = mi.Invoke(mi.IsStatic ? null : DeclaringInstance, new object[0]);
|
||||||
|
m_evaluated = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var parsedArgs = ParseArguments();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ret = mi.Invoke(mi.IsStatic ? null : DeclaringInstance, parsedArgs.ToArray());
|
||||||
|
m_evaluated = true;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
MelonLogger.Log($"Exception evaluating: {e.GetType()}, {e.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret != null)
|
||||||
|
{
|
||||||
|
m_cachedReturnValue = GetCacheObject(ret);
|
||||||
|
m_cachedReturnValue.UpdateValue();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_cachedReturnValue = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==== GUI DRAW ====
|
||||||
|
|
||||||
|
public override void DrawValue(Rect window, float width)
|
||||||
|
{
|
||||||
|
if (m_evaluated)
|
||||||
|
{
|
||||||
|
if (m_cachedReturnValue != null)
|
||||||
|
{
|
||||||
|
m_cachedReturnValue.DrawValue(window, width);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GUILayout.Label($"null (<color=#2df7b2>{ValueTypeName}</color>)", null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GUILayout.Label($"<color=grey><i>Not yet evaluated</i></color> (<color=#2df7b2>{ValueTypeName}</color>)", null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -42,15 +42,20 @@ namespace Explorer
|
|||||||
|
|
||||||
if (!label.Contains(ValueTypeName))
|
if (!label.Contains(ValueTypeName))
|
||||||
{
|
{
|
||||||
label += $" ({ValueTypeName})";
|
label += $" (<color=#2df7b2>{ValueTypeName}</color>)";
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
label = label.Replace(ValueTypeName, $"<color=#2df7b2>{ValueTypeName}</color>");
|
||||||
|
}
|
||||||
|
|
||||||
if (Value is UnityEngine.Object unityObj && !label.Contains(unityObj.name))
|
if (Value is UnityEngine.Object unityObj && !label.Contains(unityObj.name))
|
||||||
{
|
{
|
||||||
label = unityObj.name + " | " + label;
|
label = unityObj.name + " | " + label;
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI.skin.button.alignment = TextAnchor.MiddleLeft;
|
GUI.skin.button.alignment = TextAnchor.MiddleLeft;
|
||||||
if (GUILayout.Button("<color=yellow>" + label + "</color>", new GUILayoutOption[] { GUILayout.Width(width) }))
|
if (GUILayout.Button(label, new GUILayoutOption[] { GUILayout.Width(width - 15) }))
|
||||||
{
|
{
|
||||||
WindowManager.InspectObject(Value, out bool _);
|
WindowManager.InspectObject(Value, out bool _);
|
||||||
}
|
}
|
117
src/CachedObjects/Struct/CacheColor.cs
Normal file
117
src/CachedObjects/Struct/CacheColor.cs
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Explorer
|
||||||
|
{
|
||||||
|
public class CacheColor : CacheObjectBase, IExpandHeight
|
||||||
|
{
|
||||||
|
private string r = "0";
|
||||||
|
private string g = "0";
|
||||||
|
private string b = "0";
|
||||||
|
private string a = "0";
|
||||||
|
|
||||||
|
public bool IsExpanded { get; set; }
|
||||||
|
public float WhiteSpace { get; set; } = 215f;
|
||||||
|
public float ButtonWidthOffset { get; set; } = 290f;
|
||||||
|
|
||||||
|
public override void UpdateValue()
|
||||||
|
{
|
||||||
|
base.UpdateValue();
|
||||||
|
|
||||||
|
var color = (Color)Value;
|
||||||
|
|
||||||
|
r = color.r.ToString();
|
||||||
|
g = color.g.ToString();
|
||||||
|
b = color.b.ToString();
|
||||||
|
a = color.a.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void DrawValue(Rect window, float width)
|
||||||
|
{
|
||||||
|
if (CanWrite)
|
||||||
|
{
|
||||||
|
if (!IsExpanded)
|
||||||
|
{
|
||||||
|
if (GUILayout.Button("v", new GUILayoutOption[] { GUILayout.Width(25) }))
|
||||||
|
{
|
||||||
|
IsExpanded = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (GUILayout.Button("^", new GUILayoutOption[] { GUILayout.Width(25) }))
|
||||||
|
{
|
||||||
|
IsExpanded = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var c = (Color)Value;
|
||||||
|
GUI.color = c;
|
||||||
|
GUILayout.Label($"<color=#2df7b2>Color:</color> {c.ToString()}", null);
|
||||||
|
GUI.color = Color.white;
|
||||||
|
|
||||||
|
if (CanWrite && IsExpanded)
|
||||||
|
{
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
float whitespace = WhiteSpace;
|
||||||
|
if (whitespace > 0)
|
||||||
|
{
|
||||||
|
ClampLabelWidth(window, ref whitespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
GUILayout.Space(whitespace);
|
||||||
|
GUILayout.Label("R:", new GUILayoutOption[] { GUILayout.Width(30) });
|
||||||
|
r = GUILayout.TextField(r, new GUILayoutOption[] { GUILayout.Width(120) });
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
GUILayout.Space(whitespace);
|
||||||
|
GUILayout.Label("G:", new GUILayoutOption[] { GUILayout.Width(30) });
|
||||||
|
g = GUILayout.TextField(g, new GUILayoutOption[] { GUILayout.Width(120) });
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
GUILayout.Space(whitespace);
|
||||||
|
GUILayout.Label("B:", new GUILayoutOption[] { GUILayout.Width(30) });
|
||||||
|
b = GUILayout.TextField(b, new GUILayoutOption[] { GUILayout.Width(120) });
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
GUILayout.Space(whitespace);
|
||||||
|
GUILayout.Label("A:", new GUILayoutOption[] { GUILayout.Width(30) });
|
||||||
|
a = GUILayout.TextField(a, new GUILayoutOption[] { GUILayout.Width(120) });
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
// draw set value button
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
GUILayout.Space(whitespace);
|
||||||
|
if (GUILayout.Button("<color=lime>Apply</color>", new GUILayoutOption[] { GUILayout.Width(155) }))
|
||||||
|
{
|
||||||
|
SetValueFromInput();
|
||||||
|
}
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetValueFromInput()
|
||||||
|
{
|
||||||
|
if (float.TryParse(r, out float fR)
|
||||||
|
&& float.TryParse(g, out float fG)
|
||||||
|
&& float.TryParse(b, out float fB)
|
||||||
|
&& float.TryParse(a, out float fA))
|
||||||
|
{
|
||||||
|
Value = new Color(fR, fB, fG, fA);
|
||||||
|
SetValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -51,7 +51,7 @@ namespace Explorer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GUILayout.Label(Value.ToString(), null);// + "<color=yellow><i> (" + ValueType + ")</i></color>", null);
|
GUILayout.Label(Value.ToString() + "<color=#2df7b2><i> (" + ValueType + ")</i></color>", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetEnum(ref object value, int change)
|
public void SetEnum(ref object value, int change)
|
126
src/CachedObjects/Struct/CachePrimitive.cs
Normal file
126
src/CachedObjects/Struct/CachePrimitive.cs
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Reflection;
|
||||||
|
using MelonLoader;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Explorer
|
||||||
|
{
|
||||||
|
public class CachePrimitive : CacheObjectBase
|
||||||
|
{
|
||||||
|
private bool m_isBool;
|
||||||
|
private bool m_isString;
|
||||||
|
|
||||||
|
private string m_valueToString;
|
||||||
|
|
||||||
|
public MethodInfo ParseMethod => m_parseMethod ?? (m_parseMethod = Value.GetType().GetMethod("Parse", new Type[] { typeof(string) }));
|
||||||
|
private MethodInfo m_parseMethod;
|
||||||
|
|
||||||
|
public override void Init()
|
||||||
|
{
|
||||||
|
if (ValueType == null)
|
||||||
|
{
|
||||||
|
ValueType = Value?.GetType();
|
||||||
|
|
||||||
|
// has to be a string at this point
|
||||||
|
if (ValueType == null)
|
||||||
|
{
|
||||||
|
ValueType = typeof(string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ValueType == typeof(string))
|
||||||
|
{
|
||||||
|
m_isString = true;
|
||||||
|
}
|
||||||
|
else if (ValueType == typeof(bool))
|
||||||
|
{
|
||||||
|
m_isBool = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void UpdateValue()
|
||||||
|
{
|
||||||
|
base.UpdateValue();
|
||||||
|
|
||||||
|
m_valueToString = Value?.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void DrawValue(Rect window, float width)
|
||||||
|
{
|
||||||
|
if (m_isBool)
|
||||||
|
{
|
||||||
|
var b = (bool)Value;
|
||||||
|
var label = $"<color={(b ? "lime" : "red")}>{b}</color>";
|
||||||
|
|
||||||
|
if (CanWrite)
|
||||||
|
{
|
||||||
|
b = GUILayout.Toggle(b, label, null);
|
||||||
|
if (b != (bool)Value)
|
||||||
|
{
|
||||||
|
SetValueFromInput(b.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GUILayout.Label(label, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// using ValueType.Name instead of ValueTypeName, because we only want the short name.
|
||||||
|
GUILayout.Label("<color=#2df7b2><i>" + ValueType.Name + "</i></color>", new GUILayoutOption[] { GUILayout.Width(50) });
|
||||||
|
|
||||||
|
int dynSize = 25 + (m_valueToString.Length * 15);
|
||||||
|
var maxwidth = window.width - 310f;
|
||||||
|
if (CanWrite) maxwidth -= 60;
|
||||||
|
|
||||||
|
if (dynSize > maxwidth)
|
||||||
|
{
|
||||||
|
m_valueToString = GUILayout.TextArea(m_valueToString, new GUILayoutOption[] { GUILayout.MaxWidth(maxwidth) });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_valueToString = GUILayout.TextField(m_valueToString, new GUILayoutOption[] { GUILayout.MaxWidth(dynSize) });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CanWrite)
|
||||||
|
{
|
||||||
|
if (GUILayout.Button("<color=#00FF00>Apply</color>", new GUILayoutOption[] { GUILayout.Width(60) }))
|
||||||
|
{
|
||||||
|
SetValueFromInput(m_valueToString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GUILayout.Space(10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetValueFromInput(string valueString)
|
||||||
|
{
|
||||||
|
if (MemInfo == null)
|
||||||
|
{
|
||||||
|
MelonLogger.Log("Trying to SetValue but the MemberInfo is null!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_isString)
|
||||||
|
{
|
||||||
|
Value = valueString;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Value = ParseMethod.Invoke(null, new object[] { valueString });
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
MelonLogger.Log("Exception parsing value: " + e.GetType() + ", " + e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SetValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
105
src/CachedObjects/Struct/CacheQuaternion.cs
Normal file
105
src/CachedObjects/Struct/CacheQuaternion.cs
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Explorer
|
||||||
|
{
|
||||||
|
public class CacheQuaternion : CacheObjectBase, IExpandHeight
|
||||||
|
{
|
||||||
|
private string x = "0";
|
||||||
|
private string y = "0";
|
||||||
|
private string z = "0";
|
||||||
|
|
||||||
|
public bool IsExpanded { get; set; }
|
||||||
|
public float WhiteSpace { get; set; } = 215f;
|
||||||
|
public float ButtonWidthOffset { get; set; } = 290f;
|
||||||
|
|
||||||
|
public override void UpdateValue()
|
||||||
|
{
|
||||||
|
base.UpdateValue();
|
||||||
|
|
||||||
|
var euler = ((Quaternion)Value).eulerAngles;
|
||||||
|
|
||||||
|
x = euler.x.ToString();
|
||||||
|
y = euler.y.ToString();
|
||||||
|
z = euler.z.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void DrawValue(Rect window, float width)
|
||||||
|
{
|
||||||
|
if (CanWrite)
|
||||||
|
{
|
||||||
|
if (!IsExpanded)
|
||||||
|
{
|
||||||
|
if (GUILayout.Button("v", new GUILayoutOption[] { GUILayout.Width(25) }))
|
||||||
|
{
|
||||||
|
IsExpanded = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (GUILayout.Button("^", new GUILayoutOption[] { GUILayout.Width(25) }))
|
||||||
|
{
|
||||||
|
IsExpanded = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GUILayout.Label($"<color=#2df7b2>Quaternion</color>: {((Quaternion)Value).eulerAngles.ToString()}", null);
|
||||||
|
|
||||||
|
if (CanWrite && IsExpanded)
|
||||||
|
{
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
float whitespace = WhiteSpace;
|
||||||
|
if (whitespace > 0)
|
||||||
|
{
|
||||||
|
ClampLabelWidth(window, ref whitespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
GUILayout.Space(whitespace);
|
||||||
|
GUILayout.Label("X:", new GUILayoutOption[] { GUILayout.Width(30) });
|
||||||
|
x = GUILayout.TextField(x, new GUILayoutOption[] { GUILayout.Width(120) });
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
GUILayout.Space(whitespace);
|
||||||
|
GUILayout.Label("Y:", new GUILayoutOption[] { GUILayout.Width(30) });
|
||||||
|
y = GUILayout.TextField(y, new GUILayoutOption[] { GUILayout.Width(120) });
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
GUILayout.Space(whitespace);
|
||||||
|
GUILayout.Label("Z:", new GUILayoutOption[] { GUILayout.Width(30) });
|
||||||
|
z = GUILayout.TextField(z, new GUILayoutOption[] { GUILayout.Width(120) });
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
// draw set value button
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
GUILayout.Space(whitespace);
|
||||||
|
if (GUILayout.Button("<color=lime>Apply</color>", new GUILayoutOption[] { GUILayout.Width(155) }))
|
||||||
|
{
|
||||||
|
SetValueFromInput();
|
||||||
|
}
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetValueFromInput()
|
||||||
|
{
|
||||||
|
if (float.TryParse(x, out float fX)
|
||||||
|
&& float.TryParse(y, out float fY)
|
||||||
|
&& float.TryParse(z, out float fZ))
|
||||||
|
{
|
||||||
|
Value = Quaternion.Euler(new Vector3(fX, fY, fZ));
|
||||||
|
SetValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
114
src/CachedObjects/Struct/CacheRect.cs
Normal file
114
src/CachedObjects/Struct/CacheRect.cs
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Explorer
|
||||||
|
{
|
||||||
|
public class CacheRect : CacheObjectBase, IExpandHeight
|
||||||
|
{
|
||||||
|
private string x = "0";
|
||||||
|
private string y = "0";
|
||||||
|
private string w = "0";
|
||||||
|
private string h = "0";
|
||||||
|
|
||||||
|
public bool IsExpanded { get; set; }
|
||||||
|
public float WhiteSpace { get; set; } = 215f;
|
||||||
|
public float ButtonWidthOffset { get; set; } = 290f;
|
||||||
|
|
||||||
|
public override void UpdateValue()
|
||||||
|
{
|
||||||
|
base.UpdateValue();
|
||||||
|
|
||||||
|
var rect = (Rect)Value;
|
||||||
|
|
||||||
|
x = rect.x.ToString();
|
||||||
|
y = rect.y.ToString();
|
||||||
|
w = rect.width.ToString();
|
||||||
|
h = rect.height.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void DrawValue(Rect window, float width)
|
||||||
|
{
|
||||||
|
if (CanWrite)
|
||||||
|
{
|
||||||
|
if (!IsExpanded)
|
||||||
|
{
|
||||||
|
if (GUILayout.Button("v", new GUILayoutOption[] { GUILayout.Width(25) }))
|
||||||
|
{
|
||||||
|
IsExpanded = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (GUILayout.Button("^", new GUILayoutOption[] { GUILayout.Width(25) }))
|
||||||
|
{
|
||||||
|
IsExpanded = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GUILayout.Label($"<color=#2df7b2>Rect</color>: {((Rect)Value).ToString()}", null);
|
||||||
|
|
||||||
|
if (CanWrite && IsExpanded)
|
||||||
|
{
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
float whitespace = WhiteSpace;
|
||||||
|
if (whitespace > 0)
|
||||||
|
{
|
||||||
|
ClampLabelWidth(window, ref whitespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
GUILayout.Space(whitespace);
|
||||||
|
GUILayout.Label("X:", new GUILayoutOption[] { GUILayout.Width(30) });
|
||||||
|
x = GUILayout.TextField(x, new GUILayoutOption[] { GUILayout.Width(120) });
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
GUILayout.Space(whitespace);
|
||||||
|
GUILayout.Label("Y:", new GUILayoutOption[] { GUILayout.Width(30) });
|
||||||
|
y = GUILayout.TextField(y, new GUILayoutOption[] { GUILayout.Width(120) });
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
GUILayout.Space(whitespace);
|
||||||
|
GUILayout.Label("W:", new GUILayoutOption[] { GUILayout.Width(30) });
|
||||||
|
w = GUILayout.TextField(w, new GUILayoutOption[] { GUILayout.Width(120) });
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
GUILayout.Space(whitespace);
|
||||||
|
GUILayout.Label("H:", new GUILayoutOption[] { GUILayout.Width(30) });
|
||||||
|
h = GUILayout.TextField(h, new GUILayoutOption[] { GUILayout.Width(120) });
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
// draw set value button
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
GUILayout.Space(whitespace);
|
||||||
|
if (GUILayout.Button("<color=lime>Apply</color>", new GUILayoutOption[] { GUILayout.Width(155) }))
|
||||||
|
{
|
||||||
|
SetValueFromInput();
|
||||||
|
}
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetValueFromInput()
|
||||||
|
{
|
||||||
|
if (float.TryParse(x, out float fX)
|
||||||
|
&& float.TryParse(y, out float fY)
|
||||||
|
&& float.TryParse(w, out float fW)
|
||||||
|
&& float.TryParse(h, out float fH))
|
||||||
|
{
|
||||||
|
Value = new Rect(fX, fY, fW, fH);
|
||||||
|
SetValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
168
src/CachedObjects/Struct/CacheVector.cs
Normal file
168
src/CachedObjects/Struct/CacheVector.cs
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Reflection;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Explorer
|
||||||
|
{
|
||||||
|
public class CacheVector : CacheObjectBase, IExpandHeight
|
||||||
|
{
|
||||||
|
public int VectorSize = 2;
|
||||||
|
|
||||||
|
private string x = "0";
|
||||||
|
private string y = "0";
|
||||||
|
private string z = "0";
|
||||||
|
private string w = "0";
|
||||||
|
|
||||||
|
private MethodInfo m_toStringMethod;
|
||||||
|
|
||||||
|
public bool IsExpanded { get; set; }
|
||||||
|
public float WhiteSpace { get; set; } = 215f;
|
||||||
|
public float ButtonWidthOffset { get; set; } = 290f;
|
||||||
|
|
||||||
|
public override void Init()
|
||||||
|
{
|
||||||
|
if (Value is Vector2)
|
||||||
|
{
|
||||||
|
VectorSize = 2;
|
||||||
|
}
|
||||||
|
else if (Value is Vector3)
|
||||||
|
{
|
||||||
|
VectorSize = 3;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
VectorSize = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_toStringMethod = Value.GetType().GetMethod("ToString", new Type[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void UpdateValue()
|
||||||
|
{
|
||||||
|
base.UpdateValue();
|
||||||
|
|
||||||
|
if (Value is Vector2 vec2)
|
||||||
|
{
|
||||||
|
x = vec2.x.ToString();
|
||||||
|
y = vec2.y.ToString();
|
||||||
|
}
|
||||||
|
else if (Value is Vector3 vec3)
|
||||||
|
{
|
||||||
|
x = vec3.x.ToString();
|
||||||
|
y = vec3.y.ToString();
|
||||||
|
z = vec3.z.ToString();
|
||||||
|
}
|
||||||
|
else if (Value is Vector4 vec4)
|
||||||
|
{
|
||||||
|
x = vec4.x.ToString();
|
||||||
|
y = vec4.y.ToString();
|
||||||
|
z = vec4.z.ToString();
|
||||||
|
w = vec4.w.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void DrawValue(Rect window, float width)
|
||||||
|
{
|
||||||
|
if (CanWrite)
|
||||||
|
{
|
||||||
|
if (!IsExpanded)
|
||||||
|
{
|
||||||
|
if (GUILayout.Button("v", new GUILayoutOption[] { GUILayout.Width(25) }))
|
||||||
|
{
|
||||||
|
IsExpanded = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (GUILayout.Button("^", new GUILayoutOption[] { GUILayout.Width(25) }))
|
||||||
|
{
|
||||||
|
IsExpanded = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GUILayout.Label($"<color=#2df7b2>Vector{VectorSize}</color>: {(string)m_toStringMethod.Invoke(Value, new object[0])}", null);
|
||||||
|
|
||||||
|
if (CanWrite && IsExpanded)
|
||||||
|
{
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
float whitespace = WhiteSpace;
|
||||||
|
if (whitespace > 0)
|
||||||
|
{
|
||||||
|
ClampLabelWidth(window, ref whitespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
// always draw x and y
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
GUILayout.Space(whitespace);
|
||||||
|
GUILayout.Label("X:", new GUILayoutOption[] { GUILayout.Width(30) });
|
||||||
|
x = GUILayout.TextField(x, new GUILayoutOption[] { GUILayout.Width(120) });
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
GUILayout.Space(whitespace);
|
||||||
|
GUILayout.Label("Y:", new GUILayoutOption[] { GUILayout.Width(30) });
|
||||||
|
y = GUILayout.TextField(y, new GUILayoutOption[] { GUILayout.Width(120) });
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
if (VectorSize > 2)
|
||||||
|
{
|
||||||
|
// draw z
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
GUILayout.Space(whitespace);
|
||||||
|
GUILayout.Label("Z:", new GUILayoutOption[] { GUILayout.Width(30) });
|
||||||
|
z = GUILayout.TextField(z, new GUILayoutOption[] { GUILayout.Width(120) });
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
}
|
||||||
|
if (VectorSize > 3)
|
||||||
|
{
|
||||||
|
// draw w
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
GUILayout.Space(whitespace);
|
||||||
|
GUILayout.Label("W:", new GUILayoutOption[] { GUILayout.Width(30) });
|
||||||
|
w = GUILayout.TextField(w, new GUILayoutOption[] { GUILayout.Width(120) });
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
}
|
||||||
|
|
||||||
|
// draw set value button
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
GUILayout.Space(whitespace);
|
||||||
|
if (GUILayout.Button("<color=lime>Apply</color>", new GUILayoutOption[] { GUILayout.Width(155) }))
|
||||||
|
{
|
||||||
|
SetValueFromInput();
|
||||||
|
}
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetValueFromInput()
|
||||||
|
{
|
||||||
|
if (float.TryParse(x, out float fX)
|
||||||
|
&& float.TryParse(y, out float fY)
|
||||||
|
&& float.TryParse(z, out float fZ)
|
||||||
|
&& float.TryParse(w, out float fW))
|
||||||
|
{
|
||||||
|
object vector = null;
|
||||||
|
|
||||||
|
switch (VectorSize)
|
||||||
|
{
|
||||||
|
case 2: vector = new Vector2(fX, fY); break;
|
||||||
|
case 3: vector = new Vector3(fX, fY, fZ); break;
|
||||||
|
case 4: vector = new Vector4(fX, fY, fZ, fW); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vector != null)
|
||||||
|
{
|
||||||
|
Value = vector;
|
||||||
|
SetValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
@ -11,15 +12,10 @@ namespace Explorer
|
|||||||
{
|
{
|
||||||
public class CppExplorer : MelonMod
|
public class CppExplorer : MelonMod
|
||||||
{
|
{
|
||||||
public const string GUID = "com.sinai.cppexplorer";
|
public const string NAME = "CppExplorer";
|
||||||
public const string VERSION = "1.5.4";
|
public const string VERSION = "1.6.5";
|
||||||
public const string AUTHOR = "Sinai";
|
public const string AUTHOR = "Sinai";
|
||||||
|
public const string GUID = "com.sinai.cppexplorer";
|
||||||
public const string NAME = "CppExplorer"
|
|
||||||
#if Release_Unity2018
|
|
||||||
+ " (Unity 2018)"
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
|
|
||||||
public static CppExplorer Instance { get; private set; }
|
public static CppExplorer Instance { get; private set; }
|
||||||
|
|
||||||
@ -54,6 +50,8 @@ namespace Explorer
|
|||||||
{
|
{
|
||||||
Instance = this;
|
Instance = this;
|
||||||
|
|
||||||
|
InputHelper.Init();
|
||||||
|
|
||||||
new MainMenu();
|
new MainMenu();
|
||||||
new WindowManager();
|
new WindowManager();
|
||||||
|
|
||||||
@ -78,7 +76,7 @@ namespace Explorer
|
|||||||
public override void OnUpdate()
|
public override void OnUpdate()
|
||||||
{
|
{
|
||||||
// Check main toggle key input
|
// Check main toggle key input
|
||||||
if (Input.GetKeyDown(KeyCode.F7))
|
if (InputHelper.GetKeyDown(KeyCode.F7))
|
||||||
{
|
{
|
||||||
ShowMenu = !ShowMenu;
|
ShowMenu = !ShowMenu;
|
||||||
}
|
}
|
||||||
@ -86,7 +84,7 @@ namespace Explorer
|
|||||||
if (ShowMenu)
|
if (ShowMenu)
|
||||||
{
|
{
|
||||||
// Check Force-Unlock input
|
// Check Force-Unlock input
|
||||||
if (Input.GetKeyDown(KeyCode.LeftAlt))
|
if (InputHelper.GetKeyDown(KeyCode.LeftAlt))
|
||||||
{
|
{
|
||||||
ForceUnlockMouse = !ForceUnlockMouse;
|
ForceUnlockMouse = !ForceUnlockMouse;
|
||||||
}
|
}
|
||||||
|
@ -12,32 +12,19 @@
|
|||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<Deterministic>true</Deterministic>
|
<Deterministic>true</Deterministic>
|
||||||
<TargetFrameworkProfile />
|
<TargetFrameworkProfile />
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
|
||||||
<AssemblyName>CppExplorer</AssemblyName>
|
<AssemblyName>CppExplorer</AssemblyName>
|
||||||
<DebugSymbols>false</DebugSymbols>
|
<DebugSymbols>false</DebugSymbols>
|
||||||
<DebugType>none</DebugType>
|
<DebugType>none</DebugType>
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
<OutputPath>..\Release\2019\</OutputPath>
|
<OutputPath>..\Release\</OutputPath>
|
||||||
<DefineConstants>Release_2019</DefineConstants>
|
<DefineConstants />
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
<PlatformTarget>x64</PlatformTarget>
|
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release_Unity2018|AnyCPU' ">
|
|
||||||
<AssemblyName>CppExplorer_Unity2018</AssemblyName>
|
|
||||||
<DebugSymbols>false</DebugSymbols>
|
|
||||||
<DebugType>none</DebugType>
|
|
||||||
<Optimize>false</Optimize>
|
|
||||||
<OutputPath>..\Release\2018\</OutputPath>
|
|
||||||
<DefineConstants>Release_Unity2018</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<PlatformTarget>x64</PlatformTarget>
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<!-- Replace the '..\Steam\..` references with ones from your game (make sure to use the 'MelonLoader\' folder) -->
|
||||||
<Reference Include="Il2Cppmscorlib">
|
<Reference Include="Il2Cppmscorlib">
|
||||||
<HintPath>..\..\..\..\..\Steam\steamapps\common\Hellpoint\MelonLoader\Managed\Il2Cppmscorlib.dll</HintPath>
|
<HintPath>..\..\..\..\..\Steam\steamapps\common\Hellpoint\MelonLoader\Managed\Il2Cppmscorlib.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
@ -60,77 +47,50 @@
|
|||||||
<HintPath>..\..\..\..\..\Steam\steamapps\common\Hellpoint\MelonLoader\Managed\UnhollowerBaseLib.dll</HintPath>
|
<HintPath>..\..\..\..\..\Steam\steamapps\common\Hellpoint\MelonLoader\Managed\UnhollowerBaseLib.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<!-- Unity 2019 build (InputLegacyModule.dll) -->
|
<Reference Include="UnityEngine">
|
||||||
<Reference Include="UnityEngine" Condition="'$(Configuration)'=='Debug'">
|
|
||||||
<HintPath>..\..\..\Steam\steamapps\common\Hellpoint\MelonLoader\Managed\UnityEngine.dll</HintPath>
|
<HintPath>..\..\..\Steam\steamapps\common\Hellpoint\MelonLoader\Managed\UnityEngine.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="UnityEngine.CoreModule" Condition="'$(Configuration)'=='Debug'">
|
<Reference Include="UnityEngine.CoreModule">
|
||||||
<HintPath>..\..\..\Steam\steamapps\common\Hellpoint\MelonLoader\Managed\UnityEngine.CoreModule.dll</HintPath>
|
<HintPath>..\..\..\Steam\steamapps\common\Hellpoint\MelonLoader\Managed\UnityEngine.CoreModule.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="UnityEngine.IMGUIModule" Condition="'$(Configuration)'=='Debug'">
|
<Reference Include="UnityEngine.IMGUIModule">
|
||||||
<HintPath>..\..\..\Steam\steamapps\common\Hellpoint\MelonLoader\Managed\UnityEngine.IMGUIModule.dll</HintPath>
|
<HintPath>..\..\..\Steam\steamapps\common\Hellpoint\MelonLoader\Managed\UnityEngine.IMGUIModule.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="UnityEngine.InputModule" Condition="'$(Configuration)'=='Debug'">
|
<Reference Include="UnityEngine.PhysicsModule">
|
||||||
<HintPath>..\..\..\Steam\steamapps\common\Hellpoint\MelonLoader\Managed\UnityEngine.InputLegacyModule.dll</HintPath>
|
|
||||||
<Private>False</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="UnityEngine.PhysicsModule" Condition="'$(Configuration)'=='Debug'">
|
|
||||||
<HintPath>..\..\..\Steam\steamapps\common\Hellpoint\MelonLoader\Managed\UnityEngine.PhysicsModule.dll</HintPath>
|
<HintPath>..\..\..\Steam\steamapps\common\Hellpoint\MelonLoader\Managed\UnityEngine.PhysicsModule.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="UnityEngine.TextRenderingModule" Condition="'$(Configuration)'=='Debug'">
|
<Reference Include="UnityEngine.TextRenderingModule">
|
||||||
<HintPath>..\..\..\Steam\steamapps\common\Hellpoint\MelonLoader\Managed\UnityEngine.TextRenderingModule.dll</HintPath>
|
<HintPath>..\..\..\Steam\steamapps\common\Hellpoint\MelonLoader\Managed\UnityEngine.TextRenderingModule.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="UnityEngine.UI" Condition="'$(Configuration)'=='Debug'">
|
<Reference Include="UnityEngine.UI">
|
||||||
<HintPath>..\..\..\Steam\steamapps\common\Hellpoint\MelonLoader\Managed\UnityEngine.UI.dll</HintPath>
|
<HintPath>..\..\..\Steam\steamapps\common\Hellpoint\MelonLoader\Managed\UnityEngine.UI.dll</HintPath>
|
||||||
<Private>False</Private>
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<!-- Unity 2018 build (InputModule.dll) -->
|
|
||||||
<Reference Include="UnityEngine" Condition="'$(Configuration)'=='Release_Unity2018'">
|
|
||||||
<HintPath>..\..\..\Steam\steamapps\common\VRChat\MelonLoader\Managed\UnityEngine.dll</HintPath>
|
|
||||||
<Private>False</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="UnityEngine.CoreModule" Condition="'$(Configuration)'=='Release_Unity2018'">
|
|
||||||
<HintPath>..\..\..\Steam\steamapps\common\VRChat\MelonLoader\Managed\UnityEngine.CoreModule.dll</HintPath>
|
|
||||||
<Private>False</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="UnityEngine.IMGUIModule" Condition="'$(Configuration)'=='Release_Unity2018'">
|
|
||||||
<HintPath>..\..\..\Steam\steamapps\common\VRChat\MelonLoader\Managed\UnityEngine.IMGUIModule.dll</HintPath>
|
|
||||||
<Private>False</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="UnityEngine.InputModule" Condition="'$(Configuration)'=='Release_Unity2018'">
|
|
||||||
<HintPath>..\..\..\Steam\steamapps\common\VRChat\MelonLoader\Managed\UnityEngine.InputModule.dll</HintPath>
|
|
||||||
<Private>False</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="UnityEngine.PhysicsModule" Condition="'$(Configuration)'=='Release_Unity2018'">
|
|
||||||
<HintPath>..\..\..\Steam\steamapps\common\VRChat\MelonLoader\Managed\UnityEngine.PhysicsModule.dll</HintPath>
|
|
||||||
<Private>False</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="UnityEngine.TextRenderingModule" Condition="'$(Configuration)'=='Release_Unity2018'">
|
|
||||||
<HintPath>..\..\..\Steam\steamapps\common\VRChat\MelonLoader\Managed\UnityEngine.TextRenderingModule.dll</HintPath>
|
|
||||||
<Private>False</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="UnityEngine.UI" Condition="'$(Configuration)'=='Release_Unity2018'">
|
|
||||||
<HintPath>..\..\..\Steam\steamapps\common\VRChat\MelonLoader\Managed\UnityEngine.UI.dll</HintPath>
|
|
||||||
<Private>False</Private>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="CachedObjects\CacheDictionary.cs" />
|
<Compile Include="Helpers\IExpandHeight.cs" />
|
||||||
<Compile Include="CachedObjects\CacheEnum.cs" />
|
<Compile Include="CachedObjects\Struct\CacheColor.cs" />
|
||||||
<Compile Include="CachedObjects\CacheGameObject.cs" />
|
<Compile Include="CachedObjects\Object\CacheDictionary.cs" />
|
||||||
<Compile Include="CachedObjects\CacheList.cs" />
|
<Compile Include="CachedObjects\Struct\CacheEnum.cs" />
|
||||||
<Compile Include="CachedObjects\CachePrimitive.cs" />
|
<Compile Include="CachedObjects\Object\CacheGameObject.cs" />
|
||||||
<Compile Include="CachedObjects\CacheOther.cs" />
|
<Compile Include="CachedObjects\Object\CacheList.cs" />
|
||||||
<Compile Include="CachedObjects\CacheMethod.cs" />
|
<Compile Include="CachedObjects\Struct\CachePrimitive.cs" />
|
||||||
|
<Compile Include="CachedObjects\Other\CacheOther.cs" />
|
||||||
|
<Compile Include="CachedObjects\Other\CacheMethod.cs" />
|
||||||
|
<Compile Include="CachedObjects\Struct\CacheQuaternion.cs" />
|
||||||
|
<Compile Include="CachedObjects\Struct\CacheVector.cs" />
|
||||||
|
<Compile Include="CachedObjects\Struct\CacheRect.cs" />
|
||||||
<Compile Include="CppExplorer.cs" />
|
<Compile Include="CppExplorer.cs" />
|
||||||
<Compile Include="Extensions\ReflectionExtensions.cs" />
|
<Compile Include="Extensions\ReflectionExtensions.cs" />
|
||||||
<Compile Include="Unstripping\GUIUnstrip.cs" />
|
<Compile Include="Helpers\InputHelper.cs" />
|
||||||
<Compile Include="Unstripping\ScrollViewStateUnstrip.cs" />
|
<Compile Include="Tests\TestClass.cs" />
|
||||||
|
<Compile Include="UnstripFixes\GUIUnstrip.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" />
|
||||||
@ -138,8 +98,8 @@
|
|||||||
<Compile Include="Helpers\UnityHelpers.cs" />
|
<Compile Include="Helpers\UnityHelpers.cs" />
|
||||||
<Compile Include="MainMenu\InspectUnderMouse.cs" />
|
<Compile Include="MainMenu\InspectUnderMouse.cs" />
|
||||||
<Compile Include="CachedObjects\CacheObjectBase.cs" />
|
<Compile Include="CachedObjects\CacheObjectBase.cs" />
|
||||||
<Compile Include="Unstripping\SliderHandlerUnstrip.cs" />
|
<Compile Include="UnstripFixes\SliderHandlerUnstrip.cs" />
|
||||||
<Compile Include="Unstripping\UnstripExtensions.cs" />
|
<Compile Include="UnstripFixes\UnstripExtensions.cs" />
|
||||||
<Compile Include="Windows\ResizeDrag.cs" />
|
<Compile Include="Windows\ResizeDrag.cs" />
|
||||||
<Compile Include="Windows\TabViewWindow.cs" />
|
<Compile Include="Windows\TabViewWindow.cs" />
|
||||||
<Compile Include="Windows\UIWindow.cs" />
|
<Compile Include="Windows\UIWindow.cs" />
|
||||||
|
@ -7,14 +7,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CppExplorer", "CppExplorer.
|
|||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
Release_Unity2018|Any CPU = Release_Unity2018|Any CPU
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{B21DBDE3-5D6F-4726-93AB-CC3CC68BAE7D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{B21DBDE3-5D6F-4726-93AB-CC3CC68BAE7D}.Release|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{B21DBDE3-5D6F-4726-93AB-CC3CC68BAE7D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{B21DBDE3-5D6F-4726-93AB-CC3CC68BAE7D}.Release|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{B21DBDE3-5D6F-4726-93AB-CC3CC68BAE7D}.Release_Unity2018|Any CPU.ActiveCfg = Release_Unity2018|Any CPU
|
|
||||||
{B21DBDE3-5D6F-4726-93AB-CC3CC68BAE7D}.Release_Unity2018|Any CPU.Build.0 = Release_Unity2018|Any CPU
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -3,14 +3,38 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Explorer
|
namespace Explorer
|
||||||
{
|
{
|
||||||
public static class ReflectionExtensions
|
public static class ReflectionExtensions
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Extension to allow for easy, non-generic Il2Cpp casting.
|
||||||
|
/// The extension is on System.Object, but only Il2Cpp objects would be a valid target.
|
||||||
|
/// </summary>
|
||||||
public static object Il2CppCast(this object obj, Type castTo)
|
public static object Il2CppCast(this object obj, Type castTo)
|
||||||
{
|
{
|
||||||
return ReflectionHelpers.Il2CppCast(obj, castTo);
|
return ReflectionHelpers.Il2CppCast(obj, castTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Extension to safely try to get all Types from an Assembly, with a fallback for ReflectionTypeLoadException.
|
||||||
|
/// </summary>
|
||||||
|
public static IEnumerable<Type> TryGetTypes(this Assembly asm)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return asm.GetTypes();
|
||||||
|
}
|
||||||
|
catch (ReflectionTypeLoadException e)
|
||||||
|
{
|
||||||
|
return e.Types.Where(t => t != null);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return Enumerable.Empty<Type>();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
16
src/Helpers/IExpandHeight.cs
Normal file
16
src/Helpers/IExpandHeight.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Explorer
|
||||||
|
{
|
||||||
|
interface IExpandHeight
|
||||||
|
{
|
||||||
|
bool IsExpanded { get; set; }
|
||||||
|
|
||||||
|
float WhiteSpace { get; set; }
|
||||||
|
float ButtonWidthOffset { get; set; }
|
||||||
|
}
|
||||||
|
}
|
120
src/Helpers/InputHelper.cs
Normal file
120
src/Helpers/InputHelper.cs
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Reflection;
|
||||||
|
using UnityEngine;
|
||||||
|
using MelonLoader;
|
||||||
|
|
||||||
|
namespace Explorer
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Version-agnostic UnityEngine Input module using Reflection.
|
||||||
|
/// </summary>
|
||||||
|
public static class InputHelper
|
||||||
|
{
|
||||||
|
// If Input module failed to load at all
|
||||||
|
public static bool NO_INPUT;
|
||||||
|
|
||||||
|
// Base UnityEngine.Input class
|
||||||
|
private static Type Input => _input ?? (_input = ReflectionHelpers.GetTypeByName("UnityEngine.Input"));
|
||||||
|
private static Type _input;
|
||||||
|
|
||||||
|
// Cached member infos
|
||||||
|
private static PropertyInfo _mousePosition;
|
||||||
|
private static MethodInfo _getKey;
|
||||||
|
private static MethodInfo _getKeyDown;
|
||||||
|
private static MethodInfo _getMouseButton;
|
||||||
|
private static MethodInfo _getMouseButtonDown;
|
||||||
|
|
||||||
|
public static void Init()
|
||||||
|
{
|
||||||
|
if (Input == null && !TryManuallyLoadInput())
|
||||||
|
{
|
||||||
|
NO_INPUT = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cache reflection now that we know Input is loaded
|
||||||
|
|
||||||
|
_mousePosition = Input.GetProperty("mousePosition");
|
||||||
|
|
||||||
|
_getKey = Input.GetMethod("GetKey", new Type[] { typeof(KeyCode) });
|
||||||
|
_getKeyDown = Input.GetMethod("GetKeyDown", new Type[] { typeof(KeyCode) });
|
||||||
|
_getMouseButton = Input.GetMethod("GetMouseButton", new Type[] { typeof(int) });
|
||||||
|
_getMouseButtonDown = Input.GetMethod("GetMouseButtonDown", new Type[] { typeof(int) });
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma warning disable IDE1006 // Camel-case property (Unity style)
|
||||||
|
public static Vector3 mousePosition
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (NO_INPUT) return Vector3.zero;
|
||||||
|
return (Vector3)_mousePosition.GetValue(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#pragma warning restore IDE1006
|
||||||
|
|
||||||
|
public static bool GetKeyDown(KeyCode key)
|
||||||
|
{
|
||||||
|
if (NO_INPUT) return false;
|
||||||
|
return (bool)_getKeyDown.Invoke(null, new object[] { key });
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool GetKey(KeyCode key)
|
||||||
|
{
|
||||||
|
if (NO_INPUT) return false;
|
||||||
|
return (bool)_getKey.Invoke(null, new object[] { key });
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <param name="btn">1 = left, 2 = middle, 3 = right, etc</param>
|
||||||
|
public static bool GetMouseButtonDown(int btn)
|
||||||
|
{
|
||||||
|
if (NO_INPUT) return false;
|
||||||
|
return (bool)_getMouseButtonDown.Invoke(null, new object[] { btn });
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <param name="btn">1 = left, 2 = middle, 3 = right, etc</param>
|
||||||
|
public static bool GetMouseButton(int btn)
|
||||||
|
{
|
||||||
|
if (NO_INPUT) return false;
|
||||||
|
return (bool)_getMouseButton.Invoke(null, new object[] { btn });
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool TryManuallyLoadInput()
|
||||||
|
{
|
||||||
|
MelonLogger.Log("UnityEngine.Input is null, trying to load manually....");
|
||||||
|
|
||||||
|
if ((TryLoad("UnityEngine.InputLegacyModule.dll") || TryLoad("UnityEngine.CoreModule.dll")) && Input != null)
|
||||||
|
{
|
||||||
|
MelonLogger.Log("Ok!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MelonLogger.Log("Could not load Input module!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TryLoad(string module)
|
||||||
|
{
|
||||||
|
var path = $@"MelonLoader\Managed\{module}";
|
||||||
|
if (!File.Exists(path)) return false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Assembly.Load(File.ReadAllBytes(path));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
MelonLogger.Log(e.GetType() + ", " + e.Message);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -16,7 +16,18 @@ namespace Explorer
|
|||||||
public class PageHelper
|
public class PageHelper
|
||||||
{
|
{
|
||||||
public int PageOffset { get; set; }
|
public int PageOffset { get; set; }
|
||||||
public int ItemsPerPage { get; set; } = 20;
|
|
||||||
|
public int ItemsPerPage
|
||||||
|
{
|
||||||
|
get => m_itemsPerPage;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_itemsPerPage = value;
|
||||||
|
CalculateMaxOffset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private int m_itemsPerPage = 20;
|
||||||
|
|
||||||
public int ItemCount
|
public int ItemCount
|
||||||
{
|
{
|
||||||
get => m_count;
|
get => m_count;
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using UnhollowerBaseLib;
|
using UnhollowerBaseLib;
|
||||||
using UnhollowerRuntimeLib;
|
using UnhollowerRuntimeLib;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using BF = System.Reflection.BindingFlags;
|
using BF = System.Reflection.BindingFlags;
|
||||||
using MelonLoader;
|
using ILType = Il2CppSystem.Type;
|
||||||
|
|
||||||
namespace Explorer
|
namespace Explorer
|
||||||
{
|
{
|
||||||
@ -16,11 +15,11 @@ namespace Explorer
|
|||||||
{
|
{
|
||||||
public static BF CommonFlags = BF.Public | BF.Instance | BF.NonPublic | BF.Static;
|
public static BF CommonFlags = BF.Public | BF.Instance | BF.NonPublic | BF.Static;
|
||||||
|
|
||||||
public static Il2CppSystem.Type GameObjectType => Il2CppType.Of<GameObject>();
|
public static ILType GameObjectType => Il2CppType.Of<GameObject>();
|
||||||
public static Il2CppSystem.Type TransformType => Il2CppType.Of<Transform>();
|
public static ILType TransformType => Il2CppType.Of<Transform>();
|
||||||
public static Il2CppSystem.Type ObjectType => Il2CppType.Of<UnityEngine.Object>();
|
public static ILType ObjectType => Il2CppType.Of<UnityEngine.Object>();
|
||||||
public static Il2CppSystem.Type ComponentType => Il2CppType.Of<Component>();
|
public static ILType ComponentType => Il2CppType.Of<Component>();
|
||||||
public static Il2CppSystem.Type BehaviourType => Il2CppType.Of<Behaviour>();
|
public static ILType BehaviourType => Il2CppType.Of<Behaviour>();
|
||||||
|
|
||||||
private static readonly MethodInfo m_tryCastMethodInfo = typeof(Il2CppObjectBase).GetMethod("TryCast");
|
private static readonly MethodInfo m_tryCastMethodInfo = typeof(Il2CppObjectBase).GetMethod("TryCast");
|
||||||
|
|
||||||
@ -33,6 +32,94 @@ namespace Explorer
|
|||||||
.Invoke(obj, null);
|
.Invoke(obj, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsEnumerable(Type t)
|
||||||
|
{
|
||||||
|
return typeof(IEnumerable).IsAssignableFrom(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only Il2Cpp List needs this check. C# List is IEnumerable.
|
||||||
|
public static bool IsCppList(Type t)
|
||||||
|
{
|
||||||
|
if (t.IsGenericType && t.GetGenericTypeDefinition() is Type g)
|
||||||
|
{
|
||||||
|
return typeof(Il2CppSystem.Collections.Generic.List<>).IsAssignableFrom(g)
|
||||||
|
|| typeof(Il2CppSystem.Collections.Generic.IList<>).IsAssignableFrom(g);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return typeof(Il2CppSystem.Collections.IList).IsAssignableFrom(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsDictionary(Type t)
|
||||||
|
{
|
||||||
|
if (typeof(IDictionary).IsAssignableFrom(t))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (t.IsGenericType && t.GetGenericTypeDefinition() is Type g)
|
||||||
|
{
|
||||||
|
return typeof(Il2CppSystem.Collections.Generic.Dictionary<,>).IsAssignableFrom(g)
|
||||||
|
|| typeof(Il2CppSystem.Collections.Generic.IDictionary<,>).IsAssignableFrom(g);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return typeof(Il2CppSystem.Collections.IDictionary).IsAssignableFrom(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Type GetTypeByName(string fullName)
|
||||||
|
{
|
||||||
|
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
|
||||||
|
{
|
||||||
|
foreach (var type in asm.TryGetTypes())
|
||||||
|
{
|
||||||
|
if (type.FullName == fullName)
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Type GetActualType(object obj)
|
||||||
|
{
|
||||||
|
if (obj == null) return null;
|
||||||
|
|
||||||
|
if (obj is Il2CppSystem.Object ilObject)
|
||||||
|
{
|
||||||
|
var ilTypeName = ilObject.GetIl2CppType().AssemblyQualifiedName;
|
||||||
|
|
||||||
|
if (Type.GetType(ilTypeName) is Type t && !t.FullName.Contains("System.RuntimeType"))
|
||||||
|
{
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ilObject.GetType();
|
||||||
|
}
|
||||||
|
|
||||||
|
return obj.GetType();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Type[] GetAllBaseTypes(object obj)
|
||||||
|
{
|
||||||
|
var list = new List<Type>();
|
||||||
|
|
||||||
|
var type = GetActualType(obj);
|
||||||
|
list.Add(type);
|
||||||
|
|
||||||
|
while (type.BaseType != null)
|
||||||
|
{
|
||||||
|
type = type.BaseType;
|
||||||
|
list.Add(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
public static string ExceptionToString(Exception e)
|
public static string ExceptionToString(Exception e)
|
||||||
{
|
{
|
||||||
if (IsFailedGeneric(e))
|
if (IsFailedGeneric(e))
|
||||||
@ -73,84 +160,5 @@ namespace Explorer
|
|||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsArray(Type t)
|
|
||||||
{
|
|
||||||
return typeof(System.Collections.IEnumerable).IsAssignableFrom(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool IsList(Type t)
|
|
||||||
{
|
|
||||||
if (t.IsGenericType)
|
|
||||||
{
|
|
||||||
var generic = t.GetGenericTypeDefinition();
|
|
||||||
|
|
||||||
return generic.IsAssignableFrom(typeof(Il2CppSystem.Collections.Generic.List<>))
|
|
||||||
|| generic.IsAssignableFrom(typeof(Il2CppSystem.Collections.Generic.IList<>));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return t.IsAssignableFrom(typeof(Il2CppSystem.Collections.IList));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool IsDictionary(Type t)
|
|
||||||
{
|
|
||||||
return t.IsGenericType
|
|
||||||
&& t.GetGenericTypeDefinition() is Type typeDef
|
|
||||||
&& typeDef.IsAssignableFrom(typeof(Il2CppSystem.Collections.Generic.Dictionary<,>));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Type GetTypeByName(string typeName)
|
|
||||||
{
|
|
||||||
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (asm.GetType(typeName) is Type type)
|
|
||||||
{
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Type GetActualType(object obj)
|
|
||||||
{
|
|
||||||
if (obj == null) return null;
|
|
||||||
|
|
||||||
if (obj is Il2CppSystem.Object ilObject)
|
|
||||||
{
|
|
||||||
var ilTypeName = ilObject.GetIl2CppType().AssemblyQualifiedName;
|
|
||||||
|
|
||||||
if (Type.GetType(ilTypeName) is Type t && !t.FullName.Contains("System.RuntimeType"))
|
|
||||||
{
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ilObject.GetType();
|
|
||||||
}
|
|
||||||
|
|
||||||
return obj.GetType();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Type[] GetAllBaseTypes(object obj)
|
|
||||||
{
|
|
||||||
var list = new List<Type>();
|
|
||||||
|
|
||||||
var type = GetActualType(obj);
|
|
||||||
list.Add(type);
|
|
||||||
|
|
||||||
while (type.BaseType != null)
|
|
||||||
{
|
|
||||||
type = type.BaseType;
|
|
||||||
list.Add(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
return list.ToArray();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,10 @@ namespace Explorer
|
|||||||
{
|
{
|
||||||
_horizBarStyle = new GUIStyle();
|
_horizBarStyle = new GUIStyle();
|
||||||
_horizBarStyle.normal.background = Texture2D.whiteTexture;
|
_horizBarStyle.normal.background = Texture2D.whiteTexture;
|
||||||
_horizBarStyle.margin = new RectOffset(0, 0, 4, 4);
|
var rectOffset = new RectOffset();
|
||||||
|
rectOffset.top = 4;
|
||||||
|
rectOffset.bottom = 4;
|
||||||
|
_horizBarStyle.margin = rectOffset;
|
||||||
_horizBarStyle.fixedHeight = 2;
|
_horizBarStyle.fixedHeight = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +76,10 @@ namespace Explorer
|
|||||||
{
|
{
|
||||||
_horizBarSmallStyle = new GUIStyle();
|
_horizBarSmallStyle = new GUIStyle();
|
||||||
_horizBarSmallStyle.normal.background = Texture2D.whiteTexture;
|
_horizBarSmallStyle.normal.background = Texture2D.whiteTexture;
|
||||||
_horizBarSmallStyle.margin = new RectOffset(0, 0, 2, 2);
|
var rectOffset = new RectOffset();
|
||||||
|
rectOffset.top = 2;
|
||||||
|
rectOffset.bottom = 2;
|
||||||
|
_horizBarSmallStyle.margin = rectOffset;
|
||||||
_horizBarSmallStyle.fixedHeight = 1;
|
_horizBarSmallStyle.fixedHeight = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ namespace Explorer
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (m_mainCamera == null)
|
if (!m_mainCamera)
|
||||||
{
|
{
|
||||||
m_mainCamera = Camera.main;
|
m_mainCamera = Camera.main;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ namespace Explorer
|
|||||||
{
|
{
|
||||||
if (CppExplorer.ShowMenu)
|
if (CppExplorer.ShowMenu)
|
||||||
{
|
{
|
||||||
if (Input.GetKey(KeyCode.LeftShift) && Input.GetMouseButtonDown(1))
|
if (InputHelper.GetKey(KeyCode.LeftShift) && InputHelper.GetMouseButtonDown(1))
|
||||||
{
|
{
|
||||||
EnableInspect = !EnableInspect;
|
EnableInspect = !EnableInspect;
|
||||||
}
|
}
|
||||||
@ -35,7 +35,10 @@ namespace Explorer
|
|||||||
|
|
||||||
public static void InspectRaycast()
|
public static void InspectRaycast()
|
||||||
{
|
{
|
||||||
Ray ray = UnityHelpers.MainCamera.ScreenPointToRay(Input.mousePosition);
|
if (!UnityHelpers.MainCamera)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var ray = UnityHelpers.MainCamera.ScreenPointToRay(InputHelper.mousePosition);
|
||||||
|
|
||||||
if (Physics.Raycast(ray, out RaycastHit hit, 1000f))
|
if (Physics.Raycast(ray, out RaycastHit hit, 1000f))
|
||||||
{
|
{
|
||||||
@ -43,7 +46,7 @@ namespace Explorer
|
|||||||
|
|
||||||
m_objUnderMouseName = obj.transform.GetGameObjectPath();
|
m_objUnderMouseName = obj.transform.GetGameObjectPath();
|
||||||
|
|
||||||
if (Input.GetMouseButtonDown(0))
|
if (InputHelper.GetMouseButtonDown(0))
|
||||||
{
|
{
|
||||||
EnableInspect = false;
|
EnableInspect = false;
|
||||||
m_objUnderMouseName = "";
|
m_objUnderMouseName = "";
|
||||||
@ -63,7 +66,7 @@ namespace Explorer
|
|||||||
{
|
{
|
||||||
if (m_objUnderMouseName != "")
|
if (m_objUnderMouseName != "")
|
||||||
{
|
{
|
||||||
var pos = Input.mousePosition;
|
var pos = InputHelper.mousePosition;
|
||||||
var rect = new Rect(
|
var rect = new Rect(
|
||||||
pos.x - (Screen.width / 2), // x
|
pos.x - (Screen.width / 2), // x
|
||||||
Screen.height - pos.y - 50, // y
|
Screen.height - pos.y - 50, // y
|
||||||
|
@ -14,11 +14,13 @@ namespace Explorer
|
|||||||
{
|
{
|
||||||
public class ConsolePage : WindowPage
|
public class ConsolePage : WindowPage
|
||||||
{
|
{
|
||||||
public override string Name { get => "C# Console"; set => base.Name = value; }
|
public override string Name { get => "C# Console"; }
|
||||||
|
|
||||||
private ScriptEvaluator _evaluator;
|
private ScriptEvaluator _evaluator;
|
||||||
private readonly StringBuilder _sb = new StringBuilder();
|
private readonly StringBuilder _sb = new StringBuilder();
|
||||||
|
|
||||||
|
private Vector2 inputAreaScroll;
|
||||||
|
|
||||||
private string MethodInput = "";
|
private string MethodInput = "";
|
||||||
private string UsingInput = "";
|
private string UsingInput = "";
|
||||||
|
|
||||||
@ -124,7 +126,12 @@ MelonLogger.Log(""hello world"");";
|
|||||||
GUI.skin.label.alignment = TextAnchor.UpperLeft;
|
GUI.skin.label.alignment = TextAnchor.UpperLeft;
|
||||||
|
|
||||||
GUILayout.Label("Enter code here as though it is a method body:", null);
|
GUILayout.Label("Enter code here as though it is a method body:", null);
|
||||||
MethodInput = GUILayout.TextArea(MethodInput, new GUILayoutOption[] { GUILayout.Height(250) });
|
|
||||||
|
inputAreaScroll = GUIUnstrip.BeginScrollView(inputAreaScroll, new GUILayoutOption[] { GUILayout.Height(250) });
|
||||||
|
|
||||||
|
MethodInput = GUILayout.TextArea(MethodInput, new GUILayoutOption[] { GUILayout.ExpandHeight(true) });
|
||||||
|
|
||||||
|
GUIUnstrip.EndScrollView();
|
||||||
|
|
||||||
if (GUILayout.Button("<color=cyan><b>Execute</b></color>", null))
|
if (GUILayout.Button("<color=cyan><b>Execute</b></color>", null))
|
||||||
{
|
{
|
||||||
|
@ -12,27 +12,26 @@ namespace Explorer
|
|||||||
{
|
{
|
||||||
public static ScenePage Instance;
|
public static ScenePage Instance;
|
||||||
|
|
||||||
public override string Name { get => "Scene Explorer"; set => base.Name = value; }
|
public override string Name { get => "Scene Explorer"; }
|
||||||
|
|
||||||
public PageHelper Pages = new PageHelper();
|
public PageHelper Pages = new PageHelper();
|
||||||
|
|
||||||
private float m_timeOfLastUpdate = -1f;
|
private float m_timeOfLastUpdate = -1f;
|
||||||
|
private const int PASSIVE_UPDATE_INTERVAL = 1;
|
||||||
|
|
||||||
// ----- Holders for GUI elements ----- //
|
private static bool m_getRootObjectsFailed;
|
||||||
|
|
||||||
private string m_currentScene = "";
|
private static string m_currentScene = "";
|
||||||
|
|
||||||
// gameobject list
|
// gameobject list
|
||||||
private Transform m_currentTransform;
|
private Transform m_currentTransform;
|
||||||
private List<GameObjectCache> m_objectList = new List<GameObjectCache>();
|
private readonly List<GameObjectCache> m_objectList = new List<GameObjectCache>();
|
||||||
|
|
||||||
// search bar
|
// search bar
|
||||||
private bool m_searching = false;
|
private bool m_searching = false;
|
||||||
private string m_searchInput = "";
|
private string m_searchInput = "";
|
||||||
private List<GameObjectCache> m_searchResults = new List<GameObjectCache>();
|
private List<GameObjectCache> m_searchResults = new List<GameObjectCache>();
|
||||||
|
|
||||||
// ------------ Init and Update ------------ //
|
|
||||||
|
|
||||||
public override void Init()
|
public override void Init()
|
||||||
{
|
{
|
||||||
Instance = this;
|
Instance = this;
|
||||||
@ -44,59 +43,6 @@ namespace Explorer
|
|||||||
SetTransformTarget(null);
|
SetTransformTarget(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
//public void CheckOffset(ref int offset, int childCount)
|
|
||||||
//{
|
|
||||||
// if (offset >= childCount)
|
|
||||||
// {
|
|
||||||
// offset = 0;
|
|
||||||
// m_pageOffset = 0;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
public override void Update()
|
|
||||||
{
|
|
||||||
if (m_searching) return;
|
|
||||||
|
|
||||||
if (Time.time - m_timeOfLastUpdate < 1f) return;
|
|
||||||
m_timeOfLastUpdate = Time.time;
|
|
||||||
|
|
||||||
m_objectList = new List<GameObjectCache>();
|
|
||||||
|
|
||||||
var allTransforms = new List<Transform>();
|
|
||||||
|
|
||||||
// get current list of all transforms (either scene root or our current transform children)
|
|
||||||
if (m_currentTransform)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < m_currentTransform.childCount; i++)
|
|
||||||
{
|
|
||||||
allTransforms.Add(m_currentTransform.GetChild(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var scene = SceneManager.GetSceneByName(m_currentScene);
|
|
||||||
var rootObjects = scene.GetRootGameObjects();
|
|
||||||
|
|
||||||
foreach (var obj in rootObjects)
|
|
||||||
{
|
|
||||||
allTransforms.Add(obj.transform);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Pages.ItemCount = allTransforms.Count;
|
|
||||||
|
|
||||||
int offset = Pages.CalculateOffsetIndex();
|
|
||||||
|
|
||||||
// sort by childcount
|
|
||||||
allTransforms.Sort((a, b) => b.childCount.CompareTo(a.childCount));
|
|
||||||
|
|
||||||
for (int i = offset; i < offset + Pages.ItemsPerPage && i < Pages.ItemCount; i++)
|
|
||||||
{
|
|
||||||
var child = allTransforms[i];
|
|
||||||
m_objectList.Add(new GameObjectCache(child.gameObject));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetTransformTarget(Transform t)
|
public void SetTransformTarget(Transform t)
|
||||||
{
|
{
|
||||||
m_currentTransform = t;
|
m_currentTransform = t;
|
||||||
@ -104,8 +50,7 @@ namespace Explorer
|
|||||||
if (m_searching)
|
if (m_searching)
|
||||||
CancelSearch();
|
CancelSearch();
|
||||||
|
|
||||||
m_timeOfLastUpdate = -1f;
|
Update_Impl(true);
|
||||||
Update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TraverseUp()
|
public void TraverseUp()
|
||||||
@ -130,24 +75,124 @@ namespace Explorer
|
|||||||
public void CancelSearch()
|
public void CancelSearch()
|
||||||
{
|
{
|
||||||
m_searching = false;
|
m_searching = false;
|
||||||
|
|
||||||
|
if (m_getRootObjectsFailed && !m_currentTransform)
|
||||||
|
{
|
||||||
|
GetRootObjectsManual_Impl();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<GameObjectCache> SearchSceneObjects(string _search)
|
public List<GameObjectCache> SearchSceneObjects(string _search)
|
||||||
{
|
{
|
||||||
var matches = new List<GameObjectCache>();
|
var matches = new List<GameObjectCache>();
|
||||||
|
|
||||||
foreach (var obj in Resources.FindObjectsOfTypeAll<GameObject>())
|
foreach (var obj in Resources.FindObjectsOfTypeAll(ReflectionHelpers.GameObjectType))
|
||||||
{
|
{
|
||||||
if (obj.name.ToLower().Contains(_search.ToLower()) && obj.scene.name == m_currentScene)
|
var go = obj.TryCast<GameObject>();
|
||||||
|
if (go.name.ToLower().Contains(_search.ToLower()) && go.scene.name == m_currentScene)
|
||||||
{
|
{
|
||||||
matches.Add(new GameObjectCache(obj));
|
matches.Add(new GameObjectCache(go));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------- GUI Draw Function --------- //
|
public override void Update()
|
||||||
|
{
|
||||||
|
if (m_searching) return;
|
||||||
|
|
||||||
|
if (Time.time - m_timeOfLastUpdate < PASSIVE_UPDATE_INTERVAL) return;
|
||||||
|
m_timeOfLastUpdate = Time.time;
|
||||||
|
|
||||||
|
Update_Impl();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update_Impl(bool manual = false)
|
||||||
|
{
|
||||||
|
List<Transform> allTransforms = new List<Transform>();
|
||||||
|
|
||||||
|
// get current list of all transforms (either scene root or our current transform children)
|
||||||
|
if (m_currentTransform)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < m_currentTransform.childCount; i++)
|
||||||
|
{
|
||||||
|
allTransforms.Add(m_currentTransform.GetChild(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!m_getRootObjectsFailed)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var scene = SceneManager.GetSceneByName(m_currentScene);
|
||||||
|
|
||||||
|
allTransforms.AddRange(scene.GetRootGameObjects()
|
||||||
|
.Select(it => it.transform));
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
MelonLogger.Log("Exception getting root scene objects, falling back to backup method...");
|
||||||
|
|
||||||
|
m_getRootObjectsFailed = true;
|
||||||
|
allTransforms.AddRange(GetRootObjectsManual_Impl());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!manual)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
allTransforms.AddRange(GetRootObjectsManual_Impl());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Pages.ItemCount = allTransforms.Count;
|
||||||
|
|
||||||
|
int offset = Pages.CalculateOffsetIndex();
|
||||||
|
|
||||||
|
// sort by childcount
|
||||||
|
allTransforms.Sort((a, b) => b.childCount.CompareTo(a.childCount));
|
||||||
|
|
||||||
|
m_objectList.Clear();
|
||||||
|
|
||||||
|
for (int i = offset; i < offset + Pages.ItemsPerPage && i < Pages.ItemCount; i++)
|
||||||
|
{
|
||||||
|
var child = allTransforms[i];
|
||||||
|
m_objectList.Add(new GameObjectCache(child.gameObject));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerable<Transform> GetRootObjectsManual_Impl()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var array = Resources.FindObjectsOfTypeAll(ReflectionHelpers.TransformType);
|
||||||
|
|
||||||
|
var list = new List<Transform>();
|
||||||
|
foreach (var obj in array)
|
||||||
|
{
|
||||||
|
var transform = obj.TryCast<Transform>();
|
||||||
|
if (transform.parent == null && transform.gameObject.scene.name == m_currentScene)
|
||||||
|
{
|
||||||
|
list.Add(transform);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
MelonLogger.Log("Exception getting root scene objects (manual): "
|
||||||
|
+ e.GetType() + ", " + e.Message + "\r\n"
|
||||||
|
+ e.StackTrace);
|
||||||
|
return new Transform[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------- GUI Draw Function --------- //
|
||||||
|
|
||||||
public override void DrawWindow()
|
public override void DrawWindow()
|
||||||
{
|
{
|
||||||
@ -170,11 +215,9 @@ namespace Explorer
|
|||||||
|
|
||||||
GUILayout.EndVertical();
|
GUILayout.EndVertical();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch
|
||||||
{
|
{
|
||||||
MelonLogger.Log("Exception drawing ScenePage! " + e.GetType() + ", " + e.Message);
|
// supress
|
||||||
MelonLogger.Log(e.StackTrace);
|
|
||||||
m_currentTransform = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,39 +227,7 @@ namespace Explorer
|
|||||||
|
|
||||||
// Current Scene label
|
// Current Scene label
|
||||||
GUILayout.Label("Current Scene:", new GUILayoutOption[] { GUILayout.Width(120) });
|
GUILayout.Label("Current Scene:", new GUILayoutOption[] { GUILayout.Width(120) });
|
||||||
try
|
SceneChangeButtons();
|
||||||
{
|
|
||||||
// Need to do 'ToList()' so the object isn't cleaned up by Il2Cpp GC.
|
|
||||||
var scenes = SceneManager.GetAllScenes().ToList();
|
|
||||||
|
|
||||||
if (scenes.Count > 1)
|
|
||||||
{
|
|
||||||
int changeWanted = 0;
|
|
||||||
if (GUILayout.Button("<", new GUILayoutOption[] { GUILayout.Width(30) }))
|
|
||||||
{
|
|
||||||
changeWanted = -1;
|
|
||||||
}
|
|
||||||
if (GUILayout.Button(">", new GUILayoutOption[] { GUILayout.Width(30) }))
|
|
||||||
{
|
|
||||||
changeWanted = 1;
|
|
||||||
}
|
|
||||||
if (changeWanted != 0)
|
|
||||||
{
|
|
||||||
int index = scenes.IndexOf(SceneManager.GetSceneByName(m_currentScene));
|
|
||||||
index += changeWanted;
|
|
||||||
if (index > scenes.Count - 1)
|
|
||||||
{
|
|
||||||
index = 0;
|
|
||||||
}
|
|
||||||
else if (index < 0)
|
|
||||||
{
|
|
||||||
index = scenes.Count - 1;
|
|
||||||
}
|
|
||||||
m_currentScene = scenes[index].name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
GUILayout.Label("<color=cyan>" + m_currentScene + "</color>", null); //new GUILayoutOption[] { GUILayout.Width(250) });
|
GUILayout.Label("<color=cyan>" + m_currentScene + "</color>", null); //new GUILayoutOption[] { GUILayout.Width(250) });
|
||||||
|
|
||||||
GUILayout.EndHorizontal();
|
GUILayout.EndHorizontal();
|
||||||
@ -224,7 +235,9 @@ namespace Explorer
|
|||||||
// ----- GameObject Search -----
|
// ----- GameObject Search -----
|
||||||
GUILayout.BeginHorizontal(GUI.skin.box, null);
|
GUILayout.BeginHorizontal(GUI.skin.box, null);
|
||||||
GUILayout.Label("<b>Search Scene:</b>", new GUILayoutOption[] { GUILayout.Width(100) });
|
GUILayout.Label("<b>Search Scene:</b>", new GUILayoutOption[] { GUILayout.Width(100) });
|
||||||
|
|
||||||
m_searchInput = GUILayout.TextField(m_searchInput, null);
|
m_searchInput = GUILayout.TextField(m_searchInput, null);
|
||||||
|
|
||||||
if (GUILayout.Button("Search", new GUILayoutOption[] { GUILayout.Width(80) }))
|
if (GUILayout.Button("Search", new GUILayoutOption[] { GUILayout.Width(80) }))
|
||||||
{
|
{
|
||||||
Search();
|
Search();
|
||||||
@ -234,6 +247,39 @@ namespace Explorer
|
|||||||
GUILayout.Space(5);
|
GUILayout.Space(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SceneChangeButtons()
|
||||||
|
{
|
||||||
|
// Need to do 'ToList()' so the object isn't cleaned up by Il2Cpp GC.
|
||||||
|
var scenes = SceneManager.GetAllScenes().ToList();
|
||||||
|
|
||||||
|
if (scenes.Count > 1)
|
||||||
|
{
|
||||||
|
int changeWanted = 0;
|
||||||
|
if (GUILayout.Button("<", new GUILayoutOption[] { GUILayout.Width(30) }))
|
||||||
|
{
|
||||||
|
changeWanted = -1;
|
||||||
|
}
|
||||||
|
if (GUILayout.Button(">", new GUILayoutOption[] { GUILayout.Width(30) }))
|
||||||
|
{
|
||||||
|
changeWanted = 1;
|
||||||
|
}
|
||||||
|
if (changeWanted != 0)
|
||||||
|
{
|
||||||
|
int index = scenes.IndexOf(SceneManager.GetSceneByName(m_currentScene));
|
||||||
|
index += changeWanted;
|
||||||
|
if (index > scenes.Count - 1)
|
||||||
|
{
|
||||||
|
index = 0;
|
||||||
|
}
|
||||||
|
else if (index < 0)
|
||||||
|
{
|
||||||
|
index = scenes.Count - 1;
|
||||||
|
}
|
||||||
|
m_currentScene = scenes[index].name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void DrawPageButtons()
|
private void DrawPageButtons()
|
||||||
{
|
{
|
||||||
GUILayout.BeginHorizontal(null);
|
GUILayout.BeginHorizontal(null);
|
||||||
@ -246,8 +292,7 @@ namespace Explorer
|
|||||||
{
|
{
|
||||||
Pages.TurnPage(Turn.Left, ref this.scroll);
|
Pages.TurnPage(Turn.Left, ref this.scroll);
|
||||||
|
|
||||||
m_timeOfLastUpdate = -1f;
|
Update_Impl(true);
|
||||||
Update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Pages.CurrentPageLabel();
|
Pages.CurrentPageLabel();
|
||||||
@ -256,8 +301,7 @@ namespace Explorer
|
|||||||
{
|
{
|
||||||
Pages.TurnPage(Turn.Right, ref this.scroll);
|
Pages.TurnPage(Turn.Right, ref this.scroll);
|
||||||
|
|
||||||
m_timeOfLastUpdate = -1f;
|
Update_Impl(true);
|
||||||
Update();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,12 +331,24 @@ namespace Explorer
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
GUILayout.Label("Scene Root GameObjects:", null);
|
GUILayout.Label("Scene Root GameObjects:", null);
|
||||||
|
|
||||||
|
if (m_getRootObjectsFailed)
|
||||||
|
{
|
||||||
|
if (GUILayout.Button("Update Root Object List (auto-update failed!)", null))
|
||||||
|
{
|
||||||
|
Update_Impl(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_objectList.Count > 0)
|
if (m_objectList.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var obj in m_objectList)
|
for (int i = 0; i < m_objectList.Count; i++)
|
||||||
{
|
{
|
||||||
|
var obj = m_objectList[i];
|
||||||
|
|
||||||
|
if (obj == null) continue;
|
||||||
|
|
||||||
if (!obj.RefGameObject)
|
if (!obj.RefGameObject)
|
||||||
{
|
{
|
||||||
string label = "<color=red><i>null";
|
string label = "<color=red><i>null";
|
||||||
|
@ -13,7 +13,7 @@ namespace Explorer
|
|||||||
{
|
{
|
||||||
public static SearchPage Instance;
|
public static SearchPage Instance;
|
||||||
|
|
||||||
public override string Name { get => "Object Search"; set => base.Name = value; }
|
public override string Name { get => "Object Search"; }
|
||||||
|
|
||||||
private string m_searchInput = "";
|
private string m_searchInput = "";
|
||||||
private string m_typeInput = "";
|
private string m_typeInput = "";
|
||||||
@ -137,14 +137,11 @@ namespace Explorer
|
|||||||
|
|
||||||
if (m_searchResults.Count > 0)
|
if (m_searchResults.Count > 0)
|
||||||
{
|
{
|
||||||
//int offset = m_pageOffset * this.m_limit;
|
|
||||||
//if (offset >= count) m_pageOffset = 0;
|
|
||||||
int offset = Pages.CalculateOffsetIndex();
|
int offset = Pages.CalculateOffsetIndex();
|
||||||
|
|
||||||
for (int i = offset; i < offset + Pages.ItemsPerPage && i < count; i++)
|
for (int i = offset; i < offset + Pages.ItemsPerPage && i < count; i++)
|
||||||
{
|
{
|
||||||
m_searchResults[i].Draw(MainMenu.MainRect, 0f);
|
m_searchResults[i].Draw(MainMenu.MainRect, 0f);
|
||||||
//m_searchResults[i].DrawValue(MainMenu.MainRect);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -175,16 +172,6 @@ namespace Explorer
|
|||||||
GUILayout.Label("Name Contains:", new GUILayoutOption[] { GUILayout.Width(100) });
|
GUILayout.Label("Name Contains:", new GUILayoutOption[] { GUILayout.Width(100) });
|
||||||
m_searchInput = GUILayout.TextField(m_searchInput, new GUILayoutOption[] { GUILayout.Width(200) });
|
m_searchInput = GUILayout.TextField(m_searchInput, new GUILayoutOption[] { GUILayout.Width(200) });
|
||||||
|
|
||||||
//GUI.skin.label.alignment = TextAnchor.MiddleRight;
|
|
||||||
//GUILayout.Label("Results per page:", new GUILayoutOption[] { GUILayout.Width(120) });
|
|
||||||
//var resultinput = m_limit.ToString();
|
|
||||||
//resultinput = GUILayout.TextField(resultinput, new GUILayoutOption[] { GUILayout.Width(55) });
|
|
||||||
//if (int.TryParse(resultinput, out int _i) && _i > 0)
|
|
||||||
//{
|
|
||||||
// m_limit = _i;
|
|
||||||
//}
|
|
||||||
//GUI.skin.label.alignment = TextAnchor.UpperLeft;
|
|
||||||
|
|
||||||
GUILayout.EndHorizontal();
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
GUILayout.BeginHorizontal(null);
|
GUILayout.BeginHorizontal(null);
|
||||||
@ -266,7 +253,7 @@ namespace Explorer
|
|||||||
CacheResults(FindAllObjectsOfType(m_searchInput, m_typeInput));
|
CacheResults(FindAllObjectsOfType(m_searchInput, m_typeInput));
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<object> FindAllObjectsOfType(string _search, string _type)
|
private List<object> FindAllObjectsOfType(string searchQuery, string typeName)
|
||||||
{
|
{
|
||||||
Il2CppSystem.Type searchType = null;
|
Il2CppSystem.Type searchType = null;
|
||||||
|
|
||||||
@ -274,13 +261,18 @@ namespace Explorer
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var findType = ReflectionHelpers.GetTypeByName(_type);
|
if (ReflectionHelpers.GetTypeByName(typeName) is Type t)
|
||||||
searchType = Il2CppSystem.Type.GetType(findType.AssemblyQualifiedName);
|
{
|
||||||
//MelonLogger.Log("Search type: " + findType.AssemblyQualifiedName);
|
searchType = Il2CppSystem.Type.GetType(t.AssemblyQualifiedName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"Could not find a Type by the name of '{typeName}'!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
MelonLogger.Log("Exception: " + e.GetType() + ", " + e.Message + "\r\n" + e.StackTrace);
|
MelonLogger.Log("Exception getting Search Type: " + e.GetType() + ", " + e.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (TypeMode == TypeFilter.Object)
|
else if (TypeMode == TypeFilter.Object)
|
||||||
@ -298,7 +290,10 @@ namespace Explorer
|
|||||||
|
|
||||||
if (!ReflectionHelpers.ObjectType.IsAssignableFrom(searchType))
|
if (!ReflectionHelpers.ObjectType.IsAssignableFrom(searchType))
|
||||||
{
|
{
|
||||||
MelonLogger.LogError("Your Custom Class Type must inherit from UnityEngine.Object!");
|
if (searchType != null)
|
||||||
|
{
|
||||||
|
MelonLogger.LogWarning("Your Custom Class Type must inherit from UnityEngine.Object!");
|
||||||
|
}
|
||||||
return new List<object>();
|
return new List<object>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,12 +308,13 @@ namespace Explorer
|
|||||||
{
|
{
|
||||||
if (i >= 2000) break;
|
if (i >= 2000) break;
|
||||||
|
|
||||||
if (_search != "" && !obj.name.ToLower().Contains(_search.ToLower()))
|
if (searchQuery != "" && !obj.name.ToLower().Contains(searchQuery.ToLower()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (searchType == ReflectionHelpers.ComponentType && ReflectionHelpers.TransformType.IsAssignableFrom(obj.GetIl2CppType()))
|
if (searchType.FullName == ReflectionHelpers.ComponentType.FullName
|
||||||
|
&& ReflectionHelpers.TransformType.IsAssignableFrom(obj.GetIl2CppType()))
|
||||||
{
|
{
|
||||||
// Transforms shouldn't really be counted as Components, skip them.
|
// Transforms shouldn't really be counted as Components, skip them.
|
||||||
// They're more akin to GameObjects.
|
// They're more akin to GameObjects.
|
||||||
@ -376,43 +372,70 @@ namespace Explorer
|
|||||||
|
|
||||||
// ====== other ========
|
// ====== other ========
|
||||||
|
|
||||||
|
private static bool FilterName(string name)
|
||||||
|
{
|
||||||
|
// Don't really want these instances.
|
||||||
|
return !name.StartsWith("Mono")
|
||||||
|
&& !name.StartsWith("System")
|
||||||
|
&& !name.StartsWith("Il2CppSystem")
|
||||||
|
&& !name.StartsWith("Iced");
|
||||||
|
}
|
||||||
|
|
||||||
// credit: ManlyMarco (RuntimeUnityEditor)
|
// credit: ManlyMarco (RuntimeUnityEditor)
|
||||||
public static IEnumerable<object> GetInstanceClassScanner()
|
public static IEnumerable<object> GetInstanceClassScanner()
|
||||||
{
|
{
|
||||||
var query = AppDomain.CurrentDomain.GetAssemblies()
|
var query = AppDomain.CurrentDomain.GetAssemblies()
|
||||||
.Where(x => !x.FullName.StartsWith("Mono"))
|
.SelectMany(t => t.TryGetTypes())
|
||||||
.SelectMany(GetTypesSafe)
|
.Where(t => t.IsClass && !t.IsAbstract && !t.ContainsGenericParameters);
|
||||||
.Where(t => t.IsClass && !t.IsAbstract && !t.ContainsGenericParameters);
|
|
||||||
|
var flags = BindingFlags.Public | BindingFlags.Static;
|
||||||
|
var flatFlags = flags | BindingFlags.FlattenHierarchy;
|
||||||
|
|
||||||
foreach (var type in query)
|
foreach (var type in query)
|
||||||
{
|
{
|
||||||
object obj = null;
|
object obj = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
obj = type.GetProperty("Instance", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy)?.GetValue(null, null);
|
var pi = type.GetProperty("Instance", flags);
|
||||||
}
|
|
||||||
catch
|
if (pi == null)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
obj = type.GetField("Instance", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy)?.GetValue(null);
|
pi = type.GetProperty("Instance", flatFlags);
|
||||||
}
|
}
|
||||||
catch
|
|
||||||
|
if (pi != null)
|
||||||
{
|
{
|
||||||
|
obj = pi.GetValue(null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var fi = type.GetField("Instance", flags);
|
||||||
|
|
||||||
|
if (fi == null)
|
||||||
|
{
|
||||||
|
fi = type.GetField("Instance", flatFlags);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fi != null)
|
||||||
|
{
|
||||||
|
obj = fi.GetValue(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (obj != null && !obj.ToString().StartsWith("Mono"))
|
catch { }
|
||||||
|
|
||||||
|
if (obj != null)
|
||||||
{
|
{
|
||||||
|
var t = ReflectionHelpers.GetActualType(obj);
|
||||||
|
|
||||||
|
if (!FilterName(t.FullName) || ReflectionHelpers.IsEnumerable(t) || ReflectionHelpers.IsCppList(t))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
yield return obj;
|
yield return obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<Type> GetTypesSafe(Assembly asm)
|
|
||||||
{
|
|
||||||
try { return asm.GetTypes(); }
|
|
||||||
catch (ReflectionTypeLoadException e) { return e.Types.Where(x => x != null); }
|
|
||||||
catch { return Enumerable.Empty<Type>(); }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ namespace Explorer
|
|||||||
{
|
{
|
||||||
public abstract class WindowPage
|
public abstract class WindowPage
|
||||||
{
|
{
|
||||||
public virtual string Name { get; set; }
|
public virtual string Name { get; }
|
||||||
|
|
||||||
public Vector2 scroll = Vector2.zero;
|
public Vector2 scroll = Vector2.zero;
|
||||||
|
|
||||||
|
74
src/Tests/TestClass.cs
Normal file
74
src/Tests/TestClass.cs
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using MelonLoader;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Explorer.Tests
|
||||||
|
{
|
||||||
|
public class TestClass
|
||||||
|
{
|
||||||
|
public static TestClass Instance => m_instance ?? (m_instance = new TestClass());
|
||||||
|
private static TestClass m_instance;
|
||||||
|
|
||||||
|
public string this[int index]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return $"int indexer: {index}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string this[string stringIndex]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return $"string indexer: {stringIndex}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string this[int arg0, string arg1]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return $"arg0: {arg0}, arg1: {arg1}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<string> TestList = new List<string>
|
||||||
|
{
|
||||||
|
"1",
|
||||||
|
"2",
|
||||||
|
"3",
|
||||||
|
"etc..."
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Dictionary<int, List<string>> NestedDictionary = new Dictionary<int, List<string>>
|
||||||
|
{
|
||||||
|
{
|
||||||
|
123,
|
||||||
|
new List<string>
|
||||||
|
{
|
||||||
|
"One",
|
||||||
|
"Two"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
567,
|
||||||
|
new List<string>
|
||||||
|
{
|
||||||
|
"One",
|
||||||
|
"Two"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Color TestMethod(float r, float g, float b, float a)
|
||||||
|
{
|
||||||
|
return new Color(r, g, b, a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -13,16 +13,6 @@ using Harmony;
|
|||||||
|
|
||||||
namespace Explorer
|
namespace Explorer
|
||||||
{
|
{
|
||||||
// This is a manual unstrip of UnityEngine.GUI and UnityEngine.GUILayout methods.
|
|
||||||
// This code is provided "as-is".
|
|
||||||
// Taken from dnSpy output using Unity 2018.4.20.
|
|
||||||
|
|
||||||
// "Unity", Unity logos, and other Unity trademarks are trademarks or
|
|
||||||
// registered trademarks of Unity Technologies or its affiliates in the
|
|
||||||
// U.S. and elsewhere.
|
|
||||||
// https://unity3d.com/legal/terms-of-service
|
|
||||||
// https://unity3d.com/legal/terms-of-service/software
|
|
||||||
|
|
||||||
public class GUIUnstrip
|
public class GUIUnstrip
|
||||||
{
|
{
|
||||||
public static int s_ScrollControlId;
|
public static int s_ScrollControlId;
|
||||||
@ -34,18 +24,24 @@ namespace Explorer
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
#if Release_2019
|
if (m_scrollViewStatesInfo == null)
|
||||||
return GUI.scrollViewStates;
|
{
|
||||||
#else
|
try
|
||||||
return GUI.s_ScrollViewStates;
|
{
|
||||||
#endif
|
m_scrollViewStatesInfo = typeof(GUI).GetProperty("scrollViewStates");
|
||||||
|
if (m_scrollViewStatesInfo == null) throw new Exception();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
m_scrollViewStatesInfo = typeof(GUI).GetProperty("s_scrollViewStates");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (GenericStack)m_scrollViewStatesInfo?.GetValue(null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private static PropertyInfo m_scrollViewStatesInfo;
|
||||||
// ======= public methods ======= //
|
|
||||||
|
|
||||||
// Fix for GUILayoutUtility.GetLastRect().
|
|
||||||
// Calls UnstripExtensions.GetLastRectUnstripped.
|
|
||||||
|
|
||||||
public static Rect GetLastRect()
|
public static Rect GetLastRect()
|
||||||
{
|
{
|
||||||
@ -62,28 +58,7 @@ namespace Explorer
|
|||||||
return last;
|
return last;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix for GUILayout.Scroller and GUILayout.ScrollerRepeatButton, just calling fixed implementations.
|
|
||||||
|
|
||||||
public static float Scroller(Rect position, float value, float size, float leftValue, float rightValue, GUIStyle slider, GUIStyle thumb, GUIStyle leftButton, GUIStyle rightButton, bool horiz)
|
|
||||||
=> Scroller_Impl(position, value, size, leftValue, rightValue, slider, thumb, leftButton, rightButton, horiz);
|
|
||||||
|
|
||||||
public static bool ScrollerRepeatButton(int scrollerID, Rect rect, GUIStyle style)
|
|
||||||
=> ScrollerRepeatButton_Impl(scrollerID, rect, style);
|
|
||||||
|
|
||||||
// Simple unstrips for HorizontalScrollbar and VerticalScrollbar, they just call the Scroller unstrip.
|
|
||||||
|
|
||||||
public static float HorizontalScrollbar(Rect position, float value, float size, float leftValue, float rightValue, GUIStyle style)
|
|
||||||
{
|
|
||||||
return Scroller(position, value, size, leftValue, rightValue, style, GUI.skin.GetStyle(style.name + "thumb"), GUI.skin.GetStyle(style.name + "leftbutton"), GUI.skin.GetStyle(style.name + "rightbutton"), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float VerticalScrollbar(Rect position, float value, float size, float topValue, float bottomValue, GUIStyle style)
|
|
||||||
{
|
|
||||||
return Scroller(position, value, size, topValue, bottomValue, style, GUI.skin.GetStyle(style.name + "thumb"), GUI.skin.GetStyle(style.name + "upbutton"), GUI.skin.GetStyle(style.name + "downbutton"), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fix for BeginScrollView.
|
// Fix for BeginScrollView.
|
||||||
// Uses several manually unstripped methods.
|
|
||||||
|
|
||||||
public static Vector2 BeginScrollView(Vector2 scroll, params GUILayoutOption[] options)
|
public static Vector2 BeginScrollView(Vector2 scroll, params GUILayoutOption[] options)
|
||||||
{
|
{
|
||||||
@ -97,23 +72,20 @@ namespace Explorer
|
|||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
ScrollFailed = true;
|
ScrollFailed = true;
|
||||||
return scroll;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try manual unstripping implementation.
|
// Try manual implementation.
|
||||||
if (!ManualUnstripFailed)
|
if (!ManualUnstripFailed)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return BeginScrollView_Impl(scroll, false, false, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar, GUI.skin.scrollView, options);
|
return BeginScrollView_ImplLayout(scroll, false, false, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar, GUI.skin.scrollView, options);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
MelonLogger.Log("Exception on GUIUnstrip.BeginScrollView_Impl: " + e.GetType() + ", " + e.Message + "\r\n" + e.StackTrace);
|
MelonLogger.Log("Exception on manual BeginScrollView: " + e.GetType() + ", " + e.Message + "\r\n" + e.StackTrace);
|
||||||
|
|
||||||
ManualUnstripFailed = true;
|
ManualUnstripFailed = true;
|
||||||
return scroll;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,20 +109,13 @@ namespace Explorer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ======= private methods ======= //
|
private static Vector2 BeginScrollView_ImplLayout(Vector2 scrollPosition, bool alwaysShowHorizontal, bool alwaysShowVertical,
|
||||||
|
GUIStyle horizontalScrollbar, GUIStyle verticalScrollbar, GUIStyle background, params GUILayoutOption[] options)
|
||||||
// Actual unstrip of GUILayout.BeginScrollView()
|
|
||||||
|
|
||||||
private static Vector2 BeginScrollView_Impl(Vector2 scrollPosition, bool alwaysShowHorizontal, bool alwaysShowVertical, GUIStyle horizontalScrollbar,
|
|
||||||
GUIStyle verticalScrollbar, GUIStyle background, params GUILayoutOption[] options)
|
|
||||||
{
|
{
|
||||||
GUIUtility.CheckOnGUI();
|
GUIUtility.CheckOnGUI();
|
||||||
|
|
||||||
var guiscrollGroup = (GUIScrollGroup)GUILayoutUtility.BeginLayoutGroup(
|
var guiscrollGroup = GUILayoutUtility.BeginLayoutGroup(background, null, Il2CppType.Of<GUIScrollGroup>())
|
||||||
background,
|
.TryCast<GUIScrollGroup>();
|
||||||
null,
|
|
||||||
Il2CppType.Of<GUIScrollGroup>()
|
|
||||||
).Il2CppCast(typeof(GUIScrollGroup));
|
|
||||||
|
|
||||||
EventType type = Event.current.type;
|
EventType type = Event.current.type;
|
||||||
if (type == EventType.Layout)
|
if (type == EventType.Layout)
|
||||||
@ -177,16 +142,14 @@ namespace Explorer
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actual unstrip of GUI.BeginScrollView() -- note: not GUILayout.
|
private static Vector2 BeginScrollView_Impl(Rect position, Vector2 scrollPosition, Rect viewRect, bool alwaysShowHorizontal,
|
||||||
|
bool alwaysShowVertical, GUIStyle horizontalScrollbar, GUIStyle verticalScrollbar, GUIStyle background)
|
||||||
private static Vector2 BeginScrollView_Impl(Rect position, Vector2 scrollPosition, Rect viewRect, bool alwaysShowHorizontal, 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);
|
||||||
|
|
||||||
var scrollViewState = (ScrollViewState)GUIUtility.GetStateObject(Il2CppType.Of<ScrollViewState>(), controlID).Il2CppCast(typeof(ScrollViewState));
|
var scrollViewState = GUIUtility.GetStateObject(Il2CppType.Of<ScrollViewState>(), controlID).TryCast<ScrollViewState>();
|
||||||
|
|
||||||
var scrollExt = ScrollViewStateUnstrip.FromPointer(scrollViewState.Pointer);
|
var scrollExt = ScrollViewStateUnstrip.FromPointer(scrollViewState.Pointer);
|
||||||
|
|
||||||
@ -210,7 +173,7 @@ namespace Explorer
|
|||||||
|
|
||||||
ScrollStack.Push(scrollViewState);
|
ScrollStack.Push(scrollViewState);
|
||||||
|
|
||||||
Rect screenRect = new Rect(position);
|
Rect screenRect = new Rect(position.x, position.y, position.width, position.height);
|
||||||
EventType type = Event.current.type;
|
EventType type = Event.current.type;
|
||||||
if (type != EventType.Layout)
|
if (type != EventType.Layout)
|
||||||
{
|
{
|
||||||
@ -244,7 +207,7 @@ namespace Explorer
|
|||||||
}
|
}
|
||||||
if (flag2 && horizontalScrollbar != GUIStyle.none)
|
if (flag2 && horizontalScrollbar != GUIStyle.none)
|
||||||
{
|
{
|
||||||
scrollPosition.x = HorizontalScrollbar(
|
scrollPosition.x = HorizBar_Impl(
|
||||||
new Rect(
|
new Rect(
|
||||||
position.x,
|
position.x,
|
||||||
position.yMax - horizontalScrollbar.fixedHeight,
|
position.yMax - horizontalScrollbar.fixedHeight,
|
||||||
@ -266,7 +229,7 @@ namespace Explorer
|
|||||||
}
|
}
|
||||||
if (flag && verticalScrollbar != GUIStyle.none)
|
if (flag && verticalScrollbar != GUIStyle.none)
|
||||||
{
|
{
|
||||||
scrollPosition.y = VerticalScrollbar(
|
scrollPosition.y = VertBar_Impl(
|
||||||
new Rect(
|
new Rect(
|
||||||
screenRect.xMax + (float)verticalScrollbar.margin.left,
|
screenRect.xMax + (float)verticalScrollbar.margin.left,
|
||||||
screenRect.y,
|
screenRect.y,
|
||||||
@ -302,7 +265,23 @@ namespace Explorer
|
|||||||
return scrollPosition;
|
return scrollPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actual unstrip of GUI.EndScrollView()
|
public static float HorizBar_Impl(Rect position, float value, float size, float leftValue, float rightValue, GUIStyle style)
|
||||||
|
{
|
||||||
|
return Scroller_Impl(position, value, size, leftValue, rightValue, style,
|
||||||
|
GUI.skin.GetStyle(style.name + "thumb"),
|
||||||
|
GUI.skin.GetStyle(style.name + "leftbutton"),
|
||||||
|
GUI.skin.GetStyle(style.name + "rightbutton"),
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float VertBar_Impl(Rect position, float value, float size, float topValue, float bottomValue, GUIStyle style)
|
||||||
|
{
|
||||||
|
return Scroller_Impl(position, value, size, topValue, bottomValue, style,
|
||||||
|
GUI.skin.GetStyle(style.name + "thumb"),
|
||||||
|
GUI.skin.GetStyle(style.name + "upbutton"),
|
||||||
|
GUI.skin.GetStyle(style.name + "downbutton"),
|
||||||
|
false);
|
||||||
|
}
|
||||||
|
|
||||||
private static void EndScrollView_Impl(bool handleScrollWheel)
|
private static void EndScrollView_Impl(bool handleScrollWheel)
|
||||||
{
|
{
|
||||||
@ -310,16 +289,13 @@ namespace Explorer
|
|||||||
|
|
||||||
if (ScrollStack.Count <= 0) return;
|
if (ScrollStack.Count <= 0) return;
|
||||||
|
|
||||||
//ScrollViewState scrollViewState = (ScrollViewState)GUI.s_ScrollViewStates.Peek();
|
var state = ScrollStack.Peek().TryCast<ScrollViewState>();
|
||||||
var state = (ScrollViewState)ScrollStack.Peek().Il2CppCast(typeof(ScrollViewState));
|
|
||||||
//ScrollViewExtensions.Dict.TryGetValue(state.Pointer, out ScrollViewExtensions scrollExt);
|
|
||||||
var scrollExt = ScrollViewStateUnstrip.FromPointer(state.Pointer);
|
var scrollExt = ScrollViewStateUnstrip.FromPointer(state.Pointer);
|
||||||
|
|
||||||
if (scrollExt == null) throw new Exception("Could not get scrollExt!");
|
if (scrollExt == null) throw new Exception("Could not get scrollExt!");
|
||||||
|
|
||||||
GUIClip.Pop();
|
GUIClip.Pop();
|
||||||
|
|
||||||
//GUI.s_ScrollViewStates.Pop();
|
|
||||||
ScrollStack.Pop();
|
ScrollStack.Pop();
|
||||||
|
|
||||||
var position = scrollExt.position;
|
var position = scrollExt.position;
|
||||||
@ -339,15 +315,12 @@ namespace Explorer
|
|||||||
pos.y = 0f;
|
pos.y = 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// state.apply = true;
|
|
||||||
scrollExt.apply = true;
|
scrollExt.apply = true;
|
||||||
|
|
||||||
Event.current.Use();
|
Event.current.Use();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actual unstrip of GUI.Scroller
|
|
||||||
|
|
||||||
private static float Scroller_Impl(Rect position, float value, float size, float leftValue, float rightValue, GUIStyle slider, GUIStyle thumb, GUIStyle leftButton, GUIStyle rightButton, bool horiz)
|
private static float Scroller_Impl(Rect position, float value, float size, float leftValue, float rightValue, GUIStyle slider, GUIStyle thumb, GUIStyle leftButton, GUIStyle rightButton, bool horiz)
|
||||||
{
|
{
|
||||||
GUIUtility.CheckOnGUI();
|
GUIUtility.CheckOnGUI();
|
||||||
@ -368,8 +341,7 @@ namespace Explorer
|
|||||||
rect2 = new Rect(position.x, position.yMax - rightButton.fixedHeight, position.width, rightButton.fixedHeight);
|
rect2 = new Rect(position.x, position.yMax - rightButton.fixedHeight, position.width, rightButton.fixedHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
//value = GUI.Slider(position2, value, size, leftValue, rightValue, slider, thumb, horiz, controlID);
|
value = Slider_Impl(position2, value, size, leftValue, rightValue, slider, thumb, horiz, controlID);
|
||||||
value = Slider(position2, value, size, leftValue, rightValue, slider, thumb, horiz, controlID);
|
|
||||||
|
|
||||||
bool flag = Event.current.type == EventType.MouseUp;
|
bool flag = Event.current.type == EventType.MouseUp;
|
||||||
if (ScrollerRepeatButton_Impl(controlID, rect, leftButton))
|
if (ScrollerRepeatButton_Impl(controlID, rect, leftButton))
|
||||||
@ -382,8 +354,7 @@ namespace Explorer
|
|||||||
}
|
}
|
||||||
if (flag && Event.current.type == EventType.Used)
|
if (flag && Event.current.type == EventType.Used)
|
||||||
{
|
{
|
||||||
//GUI.s_ScrollControlId = 0;
|
s_ScrollControlId = 0;
|
||||||
GUIUnstrip.s_ScrollControlId = 0;
|
|
||||||
}
|
}
|
||||||
if (leftValue < rightValue)
|
if (leftValue < rightValue)
|
||||||
{
|
{
|
||||||
@ -396,11 +367,8 @@ namespace Explorer
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actual unstrip of GUI.Slider
|
public static float Slider_Impl(Rect position, float value, float size, float start, float end, GUIStyle slider, GUIStyle thumb, bool horiz, int id)
|
||||||
|
|
||||||
public static float Slider(Rect position, float value, float size, float start, float end, GUIStyle slider, GUIStyle thumb, bool horiz, int id)
|
|
||||||
{
|
{
|
||||||
//GUIUtility.CheckOnGUI();
|
|
||||||
if (id == 0)
|
if (id == 0)
|
||||||
{
|
{
|
||||||
id = GUIUtility.GetControlID(GUI.s_SliderHash, FocusType.Passive, position);
|
id = GUIUtility.GetControlID(GUI.s_SliderHash, FocusType.Passive, position);
|
||||||
@ -409,18 +377,13 @@ namespace Explorer
|
|||||||
return sliderHandler.Handle();
|
return sliderHandler.Handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actual unstrip of GUI.ScrollerRepeatButton
|
|
||||||
|
|
||||||
private static bool ScrollerRepeatButton_Impl(int scrollerID, Rect rect, GUIStyle style)
|
private static bool ScrollerRepeatButton_Impl(int scrollerID, Rect rect, GUIStyle style)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
if (GUI.DoRepeatButton(rect, GUIContent.none, style, FocusType.Passive))
|
if (GUI.DoRepeatButton(rect, GUIContent.none, style, FocusType.Passive))
|
||||||
{
|
{
|
||||||
//bool flag = GUI.s_ScrollControlId != scrollerID;
|
bool flag = s_ScrollControlId != scrollerID;
|
||||||
//GUI.s_ScrollControlId = scrollerID;
|
s_ScrollControlId = scrollerID;
|
||||||
|
|
||||||
bool flag = GUIUnstrip.s_ScrollControlId != scrollerID;
|
|
||||||
GUIUnstrip.s_ScrollControlId = scrollerID;
|
|
||||||
|
|
||||||
if (flag)
|
if (flag)
|
||||||
{
|
{
|
@ -8,17 +8,7 @@ using MelonLoader;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Explorer
|
namespace Explorer
|
||||||
{
|
{
|
||||||
// This is a manual unstrip of UnityEngine.ScrollViewState.
|
|
||||||
// This code is provided "as-is".
|
|
||||||
// Taken from dnSpy output using Unity 2018.4.20.
|
|
||||||
|
|
||||||
// "Unity", Unity logos, and other Unity trademarks are trademarks or
|
|
||||||
// registered trademarks of Unity Technologies or its affiliates in the
|
|
||||||
// U.S. and elsewhere.
|
|
||||||
// https://unity3d.com/legal/terms-of-service
|
|
||||||
// https://unity3d.com/legal/terms-of-service/software
|
|
||||||
|
|
||||||
public class ScrollViewStateUnstrip
|
public class ScrollViewStateUnstrip
|
||||||
{
|
{
|
||||||
public Rect position;
|
public Rect position;
|
@ -8,16 +8,6 @@ using UnhollowerRuntimeLib;
|
|||||||
|
|
||||||
namespace Explorer
|
namespace Explorer
|
||||||
{
|
{
|
||||||
// This is a manual unstrip of UnityEngine.SliderHandler.
|
|
||||||
// This code is provided "as-is".
|
|
||||||
// Taken from dnSpy output using Unity 2018.4.20.
|
|
||||||
|
|
||||||
// "Unity", Unity logos, and other Unity trademarks are trademarks or
|
|
||||||
// registered trademarks of Unity Technologies or its affiliates in the
|
|
||||||
// U.S. and elsewhere.
|
|
||||||
// https://unity3d.com/legal/terms-of-service
|
|
||||||
// https://unity3d.com/legal/terms-of-service/software
|
|
||||||
|
|
||||||
public struct SliderHandlerUnstrip
|
public struct SliderHandlerUnstrip
|
||||||
{
|
{
|
||||||
private readonly Rect position;
|
private readonly Rect position;
|
||||||
@ -282,7 +272,7 @@ namespace Explorer
|
|||||||
|
|
||||||
private SliderState SliderState()
|
private SliderState SliderState()
|
||||||
{
|
{
|
||||||
return (SliderState)GUIUtility.GetStateObject(Il2CppType.Of<SliderState>(), this.id).Il2CppCast(typeof(SliderState));
|
return (SliderState)GUIUtility.GetStateObject(Il2CppType.Of<SliderState>(), this.id).TryCast<SliderState>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Rect ThumbRect()
|
private Rect ThumbRect()
|
27
src/UnstripFixes/UnstripExtensions.cs
Normal file
27
src/UnstripFixes/UnstripExtensions.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Explorer
|
||||||
|
{
|
||||||
|
public static class UnstripExtensions
|
||||||
|
{
|
||||||
|
public static Rect GetLastUnstripped(this GUILayoutGroup group)
|
||||||
|
{
|
||||||
|
Rect result;
|
||||||
|
if (group.m_Cursor > 0 && group.m_Cursor <= group.entries.Count)
|
||||||
|
{
|
||||||
|
GUILayoutEntry guilayoutEntry = group.entries[group.m_Cursor - 1];
|
||||||
|
result = guilayoutEntry.rect;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = GUILayoutEntry.kDummyRect;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,50 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace Explorer
|
|
||||||
{
|
|
||||||
// "Unity", Unity logos, and other Unity trademarks are trademarks or
|
|
||||||
// registered trademarks of Unity Technologies or its affiliates in the
|
|
||||||
// U.S. and elsewhere.
|
|
||||||
// https://unity3d.com/legal/terms-of-service
|
|
||||||
// https://unity3d.com/legal/terms-of-service/software
|
|
||||||
|
|
||||||
public static class UnstripExtensions
|
|
||||||
{
|
|
||||||
// This is a manual unstrip of GUILayoutGroup.GetLast().
|
|
||||||
// I'm using it as an Extension because it's easier this way.
|
|
||||||
|
|
||||||
public static Rect GetLastUnstripped(this GUILayoutGroup group)
|
|
||||||
{
|
|
||||||
Rect result;
|
|
||||||
if (group.m_Cursor == 0)
|
|
||||||
{
|
|
||||||
Debug.LogError("You cannot call GetLast immediately after beginning a group.");
|
|
||||||
result = GUILayoutEntry.kDummyRect;
|
|
||||||
}
|
|
||||||
else if (group.m_Cursor <= group.entries.Count)
|
|
||||||
{
|
|
||||||
GUILayoutEntry guilayoutEntry = group.entries[group.m_Cursor - 1];
|
|
||||||
result = guilayoutEntry.rect;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.LogError(string.Concat(new object[]
|
|
||||||
{
|
|
||||||
"Getting control ",
|
|
||||||
group.m_Cursor,
|
|
||||||
"'s position in a group with only ",
|
|
||||||
group.entries.Count,
|
|
||||||
" controls when doing ",
|
|
||||||
Event.current.type
|
|
||||||
}));
|
|
||||||
result = GUILayoutEntry.kDummyRect;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -29,9 +29,17 @@ namespace Explorer
|
|||||||
private Vector2 m_compScroll = Vector2.zero;
|
private Vector2 m_compScroll = Vector2.zero;
|
||||||
private PageHelper CompPages = new PageHelper();
|
private PageHelper CompPages = new PageHelper();
|
||||||
|
|
||||||
|
private readonly Vector3[] m_cachedInput = new Vector3[3];
|
||||||
private float m_translateAmount = 0.3f;
|
private float m_translateAmount = 0.3f;
|
||||||
private float m_rotateAmount = 50f;
|
private float m_rotateAmount = 50f;
|
||||||
private float m_scaleAmount = 0.1f;
|
private float m_scaleAmount = 0.1f;
|
||||||
|
private bool m_freeze;
|
||||||
|
private Vector3 m_frozenPosition;
|
||||||
|
private Quaternion m_frozenRotation;
|
||||||
|
private Vector3 m_frozenScale;
|
||||||
|
private bool m_autoApplyTransform;
|
||||||
|
private bool m_autoUpdateTransform;
|
||||||
|
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 = "";
|
||||||
@ -40,12 +48,6 @@ namespace Explorer
|
|||||||
|
|
||||||
public bool GetObjectAsGameObject()
|
public bool GetObjectAsGameObject()
|
||||||
{
|
{
|
||||||
if (Target == null)
|
|
||||||
{
|
|
||||||
MelonLogger.Log("Target is null!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var targetType = Target.GetType();
|
var targetType = Target.GetType();
|
||||||
|
|
||||||
if (targetType == typeof(GameObject))
|
if (targetType == typeof(GameObject))
|
||||||
@ -73,43 +75,85 @@ namespace Explorer
|
|||||||
|
|
||||||
m_name = m_object.name;
|
m_name = m_object.name;
|
||||||
m_scene = string.IsNullOrEmpty(m_object.scene.name)
|
m_scene = string.IsNullOrEmpty(m_object.scene.name)
|
||||||
? "None"
|
? "None (Asset/Resource)"
|
||||||
: m_object.scene.name;
|
: m_object.scene.name;
|
||||||
|
|
||||||
|
CacheTransformValues();
|
||||||
|
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CacheTransformValues()
|
||||||
|
{
|
||||||
|
if (m_localContext)
|
||||||
|
{
|
||||||
|
m_cachedInput[0] = m_object.transform.localPosition;
|
||||||
|
m_cachedInput[1] = m_object.transform.localEulerAngles;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_cachedInput[0] = m_object.transform.position;
|
||||||
|
m_cachedInput[1] = m_object.transform.eulerAngles;
|
||||||
|
}
|
||||||
|
m_cachedInput[2] = m_object.transform.localScale;
|
||||||
|
}
|
||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (Target == null)
|
||||||
|
{
|
||||||
|
MelonLogger.Log("Target is null!");
|
||||||
|
DestroyWindow();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (Target is UnityEngine.Object uObj)
|
||||||
|
{
|
||||||
|
if (!uObj)
|
||||||
|
{
|
||||||
|
MelonLogger.Log("Target was destroyed!");
|
||||||
|
DestroyWindow();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!m_object && !GetObjectAsGameObject())
|
if (!m_object && !GetObjectAsGameObject())
|
||||||
{
|
{
|
||||||
throw new Exception("Object is null!");
|
throw new Exception("Object is null!");
|
||||||
}
|
}
|
||||||
|
|
||||||
var list = new List<Transform>();
|
if (m_freeze)
|
||||||
|
{
|
||||||
|
if (m_localContext)
|
||||||
|
{
|
||||||
|
m_object.transform.localPosition = m_frozenPosition;
|
||||||
|
m_object.transform.localRotation = m_frozenRotation;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_object.transform.position = m_frozenPosition;
|
||||||
|
m_object.transform.rotation = m_frozenRotation;
|
||||||
|
}
|
||||||
|
m_object.transform.localScale = m_frozenScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
// update child objects
|
||||||
|
var childList = new List<Transform>();
|
||||||
for (int i = 0; i < m_object.transform.childCount; i++)
|
for (int i = 0; i < m_object.transform.childCount; i++)
|
||||||
{
|
{
|
||||||
list.Add(m_object.transform.GetChild(i));
|
childList.Add(m_object.transform.GetChild(i));
|
||||||
}
|
}
|
||||||
list.Sort((a, b) => b.childCount.CompareTo(a.childCount));
|
childList.Sort((a, b) => b.childCount.CompareTo(a.childCount));
|
||||||
m_children = list.ToArray();
|
m_children = childList.ToArray();
|
||||||
|
|
||||||
ChildPages.ItemCount = m_children.Length;
|
ChildPages.ItemCount = m_children.Length;
|
||||||
|
|
||||||
var list2 = new List<Component>();
|
// update components
|
||||||
foreach (var comp in m_object.GetComponents(ReflectionHelpers.ComponentType))
|
var compList = new Il2CppSystem.Collections.Generic.List<Component>();
|
||||||
{
|
m_object.GetComponentsInternal(ReflectionHelpers.ComponentType, true, false, true, false, compList);
|
||||||
var ilType = comp.GetIl2CppType();
|
|
||||||
if (ilType == ReflectionHelpers.TransformType)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
list2.Add(comp);
|
m_components = compList.ToArray();
|
||||||
}
|
|
||||||
m_components = list2.ToArray();
|
|
||||||
|
|
||||||
CompPages.ItemCount = m_components.Length;
|
CompPages.ItemCount = m_components.Length;
|
||||||
}
|
}
|
||||||
@ -412,6 +456,16 @@ namespace Explorer
|
|||||||
m_object.hideFlags |= HideFlags.DontUnloadUnusedAsset;
|
m_object.hideFlags |= HideFlags.DontUnloadUnusedAsset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var lbl = m_freeze ? "<color=lime>Unfreeze</color>" : "<color=orange>Freeze Pos/Rot</color>";
|
||||||
|
if (GUILayout.Button(lbl, new GUILayoutOption[] { GUILayout.Width(110) }))
|
||||||
|
{
|
||||||
|
m_freeze = !m_freeze;
|
||||||
|
if (m_freeze)
|
||||||
|
{
|
||||||
|
UpdateFreeze();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GUILayout.EndHorizontal();
|
GUILayout.EndHorizontal();
|
||||||
GUILayout.BeginHorizontal(null);
|
GUILayout.BeginHorizontal(null);
|
||||||
|
|
||||||
@ -436,10 +490,52 @@ namespace Explorer
|
|||||||
|
|
||||||
GUILayout.BeginVertical(GUI.skin.box, null);
|
GUILayout.BeginVertical(GUI.skin.box, null);
|
||||||
|
|
||||||
var t = m_object.transform;
|
m_cachedInput[0] = TranslateControl(TranslateType.Position, ref m_translateAmount, false);
|
||||||
TranslateControl(t, TranslateType.Position, ref m_translateAmount, false);
|
m_cachedInput[1] = TranslateControl(TranslateType.Rotation, ref m_rotateAmount, true);
|
||||||
TranslateControl(t, TranslateType.Rotation, ref m_rotateAmount, true);
|
m_cachedInput[2] = TranslateControl(TranslateType.Scale, ref m_scaleAmount, false);
|
||||||
TranslateControl(t, TranslateType.Scale, ref m_scaleAmount, false);
|
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
if (GUILayout.Button("<color=lime>Apply to Transform</color>", null) || m_autoApplyTransform)
|
||||||
|
{
|
||||||
|
if (m_localContext)
|
||||||
|
{
|
||||||
|
m_object.transform.localPosition = m_cachedInput[0];
|
||||||
|
m_object.transform.localEulerAngles = m_cachedInput[1];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_object.transform.position = m_cachedInput[0];
|
||||||
|
m_object.transform.eulerAngles = m_cachedInput[1];
|
||||||
|
}
|
||||||
|
m_object.transform.localScale = m_cachedInput[2];
|
||||||
|
|
||||||
|
if (m_freeze)
|
||||||
|
{
|
||||||
|
UpdateFreeze();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (GUILayout.Button("<color=lime>Update from Transform</color>", null) || m_autoUpdateTransform)
|
||||||
|
{
|
||||||
|
CacheTransformValues();
|
||||||
|
}
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
GUILayout.BeginHorizontal(null);
|
||||||
|
BoolToggle(ref m_autoApplyTransform, "Auto-apply to Transform?");
|
||||||
|
BoolToggle(ref m_autoUpdateTransform, "Auto-update from transform?");
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
bool b = m_localContext;
|
||||||
|
b = GUILayout.Toggle(b, "<color=" + (b ? "lime" : "red") + ">Use local transform values?</color>", null);
|
||||||
|
if (b != m_localContext)
|
||||||
|
{
|
||||||
|
m_localContext = b;
|
||||||
|
CacheTransformValues();
|
||||||
|
if (m_freeze)
|
||||||
|
{
|
||||||
|
UpdateFreeze();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GUILayout.EndVertical();
|
GUILayout.EndVertical();
|
||||||
|
|
||||||
@ -453,6 +549,30 @@ namespace Explorer
|
|||||||
GUILayout.EndVertical();
|
GUILayout.EndVertical();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateFreeze()
|
||||||
|
{
|
||||||
|
if (m_localContext)
|
||||||
|
{
|
||||||
|
m_frozenPosition = m_object.transform.localPosition;
|
||||||
|
m_frozenRotation = m_object.transform.localRotation;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_frozenPosition = m_object.transform.position;
|
||||||
|
m_frozenRotation = m_object.transform.rotation;
|
||||||
|
}
|
||||||
|
m_frozenScale = m_object.transform.localScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BoolToggle(ref bool value, string message)
|
||||||
|
{
|
||||||
|
string lbl = "<color=";
|
||||||
|
lbl += value ? "lime" : "red";
|
||||||
|
lbl += $">{message}</color>";
|
||||||
|
|
||||||
|
value = GUILayout.Toggle(value, lbl, null);
|
||||||
|
}
|
||||||
|
|
||||||
public enum TranslateType
|
public enum TranslateType
|
||||||
{
|
{
|
||||||
Position,
|
Position,
|
||||||
@ -460,50 +580,55 @@ namespace Explorer
|
|||||||
Scale
|
Scale
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TranslateControl(Transform transform, TranslateType mode, ref float amount, bool multByTime)
|
private Vector3 TranslateControl(TranslateType mode, ref float amount, bool multByTime)
|
||||||
{
|
{
|
||||||
GUILayout.BeginHorizontal(null);
|
GUILayout.BeginHorizontal(null);
|
||||||
GUILayout.Label("<color=cyan><b>" + mode + "</b></color>:", new GUILayoutOption[] { GUILayout.Width(65) });
|
GUILayout.Label($"<color=cyan><b>{(m_localContext ? "Local " : "")}{mode}</b></color>:",
|
||||||
|
new GUILayoutOption[] { GUILayout.Width(m_localContext ? 110 : 65) });
|
||||||
|
|
||||||
Vector3 vector = Vector3.zero;
|
var transform = m_object.transform;
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case TranslateType.Position: vector = transform.localPosition; break;
|
case TranslateType.Position:
|
||||||
case TranslateType.Rotation: vector = transform.localRotation.eulerAngles; break;
|
var pos = m_localContext ? transform.localPosition : transform.position;
|
||||||
case TranslateType.Scale: vector = transform.localScale; break;
|
GUILayout.Label(pos.ToString(), new GUILayoutOption[] { GUILayout.Width(250) });
|
||||||
|
break;
|
||||||
|
case TranslateType.Rotation:
|
||||||
|
var rot = m_localContext ? transform.localEulerAngles : transform.eulerAngles;
|
||||||
|
GUILayout.Label(rot.ToString(), new GUILayoutOption[] { GUILayout.Width(250) });
|
||||||
|
break;
|
||||||
|
case TranslateType.Scale:
|
||||||
|
GUILayout.Label(transform.localScale.ToString(), new GUILayoutOption[] { GUILayout.Width(250) });
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
GUILayout.Label(vector.ToString(), new GUILayoutOption[] { GUILayout.Width(250) });
|
|
||||||
GUILayout.EndHorizontal();
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
Vector3 input = m_cachedInput[(int)mode];
|
||||||
|
|
||||||
GUILayout.BeginHorizontal(null);
|
GUILayout.BeginHorizontal(null);
|
||||||
GUI.skin.label.alignment = TextAnchor.MiddleRight;
|
GUI.skin.label.alignment = TextAnchor.MiddleRight;
|
||||||
|
|
||||||
GUILayout.Label("<color=cyan>X:</color>", new GUILayoutOption[] { GUILayout.Width(20) });
|
GUILayout.Label("<color=cyan>X:</color>", new GUILayoutOption[] { GUILayout.Width(20) });
|
||||||
PlusMinusFloat(ref vector.x, amount, multByTime);
|
PlusMinusFloat(ref input.x, amount, multByTime);
|
||||||
|
|
||||||
GUILayout.Label("<color=cyan>Y:</color>", new GUILayoutOption[] { GUILayout.Width(20) });
|
GUILayout.Label("<color=cyan>Y:</color>", new GUILayoutOption[] { GUILayout.Width(20) });
|
||||||
PlusMinusFloat(ref vector.y, amount, multByTime);
|
PlusMinusFloat(ref input.y, amount, multByTime);
|
||||||
|
|
||||||
GUILayout.Label("<color=cyan>Z:</color>", new GUILayoutOption[] { GUILayout.Width(20) });
|
GUILayout.Label("<color=cyan>Z:</color>", new GUILayoutOption[] { GUILayout.Width(20) });
|
||||||
PlusMinusFloat(ref vector.z, amount, multByTime);
|
PlusMinusFloat(ref input.z, amount, multByTime);
|
||||||
|
|
||||||
switch (mode)
|
|
||||||
{
|
|
||||||
case TranslateType.Position: transform.localPosition = vector; break;
|
|
||||||
case TranslateType.Rotation: transform.localRotation = Quaternion.Euler(vector); break;
|
|
||||||
case TranslateType.Scale: transform.localScale = vector; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
GUILayout.Label("+/-:", new GUILayoutOption[] { GUILayout.Width(30) });
|
GUILayout.Label("+/-:", new GUILayoutOption[] { GUILayout.Width(30) });
|
||||||
var input = amount.ToString("F3");
|
var amountInput = amount.ToString("F3");
|
||||||
input = GUILayout.TextField(input, new GUILayoutOption[] { GUILayout.Width(40) });
|
amountInput = GUILayout.TextField(amountInput, new GUILayoutOption[] { GUILayout.Width(60) });
|
||||||
if (float.TryParse(input, out float f))
|
if (float.TryParse(amountInput, out float f))
|
||||||
{
|
{
|
||||||
amount = f;
|
amount = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI.skin.label.alignment = TextAnchor.UpperLeft;
|
GUI.skin.label.alignment = TextAnchor.UpperLeft;
|
||||||
GUILayout.EndHorizontal();
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PlusMinusFloat(ref float f, float amount, bool multByTime)
|
private void PlusMinusFloat(ref float f, float amount, bool multByTime)
|
||||||
@ -523,7 +648,5 @@ namespace Explorer
|
|||||||
f += multByTime ? amount * Time.deltaTime : amount;
|
f += multByTime ? amount * Time.deltaTime : amount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,6 @@ namespace Explorer
|
|||||||
private CacheObjectBase[] m_cachedMembersFiltered;
|
private CacheObjectBase[] m_cachedMembersFiltered;
|
||||||
|
|
||||||
public PageHelper Pages = new PageHelper();
|
public PageHelper Pages = new PageHelper();
|
||||||
//private int m_pageOffset;
|
|
||||||
//private int m_limitPerPage = 20;
|
|
||||||
|
|
||||||
private bool m_autoUpdate = false;
|
private bool m_autoUpdate = false;
|
||||||
private string m_search = "";
|
private string m_search = "";
|
||||||
@ -69,6 +67,20 @@ namespace Explorer
|
|||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
|
if (Target == null)
|
||||||
|
{
|
||||||
|
DestroyWindow();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (Target is UnityEngine.Object uObj)
|
||||||
|
{
|
||||||
|
if (!uObj)
|
||||||
|
{
|
||||||
|
DestroyWindow();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_cachedMembersFiltered = m_allCachedMembers.Where(x => ShouldProcessMember(x)).ToArray();
|
m_cachedMembersFiltered = m_allCachedMembers.Where(x => ShouldProcessMember(x)).ToArray();
|
||||||
|
|
||||||
if (m_autoUpdate)
|
if (m_autoUpdate)
|
||||||
@ -150,10 +162,20 @@ namespace Explorer
|
|||||||
name += " (";
|
name += " (";
|
||||||
foreach (var param in mi.GetParameters())
|
foreach (var param in mi.GetParameters())
|
||||||
{
|
{
|
||||||
name += param.ParameterType.Name + ", ";
|
name += $"{param.ParameterType.Name} {param.Name}, ";
|
||||||
}
|
}
|
||||||
name += ")";
|
name += ")";
|
||||||
}
|
}
|
||||||
|
else if (member is PropertyInfo pi)
|
||||||
|
{
|
||||||
|
name += " (";
|
||||||
|
foreach (var param in pi.GetIndexParameters())
|
||||||
|
{
|
||||||
|
name += $"{param.ParameterType.Name} {param.Name}, ";
|
||||||
|
}
|
||||||
|
name += ")";
|
||||||
|
}
|
||||||
|
|
||||||
if (names.Contains(name))
|
if (names.Contains(name))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
@ -34,15 +34,17 @@ namespace Explorer
|
|||||||
//var r = GUILayoutUtility.GetLastRect();
|
//var r = GUILayoutUtility.GetLastRect();
|
||||||
var r = GUIUnstrip.GetLastRect();
|
var r = GUIUnstrip.GetLastRect();
|
||||||
|
|
||||||
Vector2 mouse = GUIUtility.ScreenToGUIPoint(new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y));
|
var mousePos = InputHelper.mousePosition;
|
||||||
|
|
||||||
if (r.Contains(mouse) && Input.GetMouseButtonDown(0))
|
Vector2 mouse = GUIUtility.ScreenToGUIPoint(new Vector2(mousePos.x, Screen.height - mousePos.y));
|
||||||
|
|
||||||
|
if (r.Contains(mouse) && InputHelper.GetMouseButtonDown(0))
|
||||||
{
|
{
|
||||||
isResizing = true;
|
isResizing = true;
|
||||||
m_currentWindow = ID;
|
m_currentWindow = ID;
|
||||||
m_currentResize = new Rect(mouse.x, mouse.y, _rect.width, _rect.height);
|
m_currentResize = new Rect(mouse.x, mouse.y, _rect.width, _rect.height);
|
||||||
}
|
}
|
||||||
else if (!Input.GetMouseButton(0))
|
else if (!InputHelper.GetMouseButton(0))
|
||||||
{
|
{
|
||||||
isResizing = false;
|
isResizing = false;
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ namespace Explorer
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void Init() { }
|
public override void Init() { }
|
||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
while (TargetTabID >= WindowManager.Windows.Count)
|
while (TargetTabID >= WindowManager.Windows.Count)
|
||||||
|
@ -90,7 +90,7 @@ namespace Explorer
|
|||||||
{
|
{
|
||||||
createdNew = false;
|
createdNew = false;
|
||||||
|
|
||||||
if (Input.GetKey(KeyCode.LeftShift))
|
if (InputHelper.GetKey(KeyCode.LeftShift))
|
||||||
{
|
{
|
||||||
forceReflection = true;
|
forceReflection = true;
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ namespace Explorer
|
|||||||
|
|
||||||
if (!equals && iObj is Il2CppSystem.Object iCurrent && window.Target is Il2CppSystem.Object iTarget)
|
if (!equals && iObj is Il2CppSystem.Object iCurrent && window.Target is Il2CppSystem.Object iTarget)
|
||||||
{
|
{
|
||||||
if (iCurrent.GetIl2CppType() != iTarget.GetIl2CppType())
|
if (iCurrent.GetIl2CppType().FullName != iTarget.GetIl2CppType().FullName)
|
||||||
{
|
{
|
||||||
if (iCurrent is Transform transform)
|
if (iCurrent is Transform transform)
|
||||||
{
|
{
|
||||||
@ -192,7 +192,8 @@ namespace Explorer
|
|||||||
|
|
||||||
private static bool RectContainsMouse(Rect rect)
|
private static bool RectContainsMouse(Rect rect)
|
||||||
{
|
{
|
||||||
return rect.Contains(new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y));
|
var mousePos = InputHelper.mousePosition;
|
||||||
|
return rect.Contains(new Vector2(mousePos.x, Screen.height - mousePos.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int NextWindowID()
|
public static int NextWindowID()
|
||||||
|
Reference in New Issue
Block a user