Compare commits

..

9 Commits

9 changed files with 108 additions and 34 deletions

View File

@ -6,6 +6,10 @@
An in-game explorer and a suite of debugging tools for <a href="https://docs.unity3d.com/Manual/IL2CPP.html">IL2CPP</a> and <b>Mono</b> Unity games, to aid with modding development.
</p>
<p align="center">
Supports most Unity games from versions 5.2 to 2020+.
</p>
## Releases [![](https://img.shields.io/github/release/sinai-dev/UnityExplorer.svg?label=release%20notes)](../../releases/latest) [![](https://img.shields.io/github/downloads/sinai-dev/UnityExplorer/total.svg)](../../releases) [![](https://img.shields.io/github/downloads/sinai-dev/UnityExplorer/latest/total.svg)](../../releases/latest)
| Mod Loader | IL2CPP | Mono |

View File

@ -19,11 +19,13 @@ namespace UnityExplorer.Core.Config
public static ConfigElement<KeyCode> Main_Menu_Toggle;
public static ConfigElement<bool> Force_Unlock_Mouse;
public static ConfigElement<bool> Aggressive_Force_Unlock;
public static ConfigElement<MenuPages> Default_Tab;
public static ConfigElement<int> Default_Page_Limit;
public static ConfigElement<string> Default_Output_Path;
public static ConfigElement<bool> Log_Unity_Debug;
public static ConfigElement<bool> Hide_On_Startup;
public static ConfigElement<float> Startup_Delay_Time;
public static ConfigElement<string> Last_Window_Anchors;
public static ConfigElement<string> Last_Window_Position;
@ -77,6 +79,10 @@ namespace UnityExplorer.Core.Config
"Force the Cursor to be unlocked (visible) when the UnityExplorer menu is open.",
true);
Aggressive_Force_Unlock = new ConfigElement<bool>("Aggressive Mouse Unlock",
"Use WaitForEndOfFrame to aggressively force the Mouse to be unlocked (requires game restart).",
false);
Default_Page_Limit = new ConfigElement<int>("Default Page Limit",
"The default maximum number of elements per 'page' in UnityExplorer.",
25);
@ -85,6 +91,10 @@ namespace UnityExplorer.Core.Config
"The default output path when exporting things from UnityExplorer.",
Path.Combine(ExplorerCore.Loader.ExplorerFolder, "Output"));
Startup_Delay_Time = new ConfigElement<float>("Startup Delay Time",
"The delay on startup before the UI is created.",
1f);
// Internal configs
Last_Window_Anchors = new ConfigElement<string>("Last_Window_Anchors",

View File

@ -7,6 +7,7 @@ using BF = System.Reflection.BindingFlags;
using UnityExplorer.Core.Config;
using UnityExplorer.Core;
using UnityExplorer.UI;
using System.Collections;
#if ML
using Harmony;
#else
@ -48,6 +49,34 @@ namespace UnityExplorer.Core.Input
Unlock = ConfigManager.Force_Unlock_Mouse.Value;
ConfigManager.Force_Unlock_Mouse.OnValueChanged += (bool val) => { Unlock = val; };
if (ConfigManager.Aggressive_Force_Unlock.Value)
SetupAggressiveUnlock();
}
public static void SetupAggressiveUnlock()
{
try
{
RuntimeProvider.Instance.StartCoroutine(AggressiveUnlockCoroutine());
}
catch (Exception ex)
{
ExplorerCore.LogWarning($"Exception setting up Aggressive Mouse Unlock: {ex}");
}
}
private static readonly WaitForEndOfFrame _waitForEndOfFrame = new WaitForEndOfFrame();
private static IEnumerator AggressiveUnlockCoroutine()
{
while (true)
{
yield return _waitForEndOfFrame;
if (UIManager.ShowMenu)
UpdateCursorControl();
}
}
public static void UpdateCursorControl()

View File

@ -164,8 +164,10 @@ namespace UnityExplorer.Core.Runtime.Il2Cpp
internal static PropertyInfo _normalColorProp;
internal static PropertyInfo _highlightColorProp;
internal static PropertyInfo _pressedColorProp;
internal static PropertyInfo _disabledColorProp;
public override void SetColorBlock(Selectable selectable, Color? normal = null, Color? highlighted = null, Color? pressed = null)
public override void SetColorBlock(Selectable selectable, Color? normal = null, Color? highlighted = null, Color? pressed = null,
Color? disabled = null)
{
var colors = selectable.colors;
@ -183,6 +185,8 @@ namespace UnityExplorer.Core.Runtime.Il2Cpp
_highlightColorProp = high;
if (ReflectionUtility.GetPropertyInfo(typeof(ColorBlock), "pressedColor") is PropertyInfo pres && pres.CanWrite)
_pressedColorProp = pres;
if (ReflectionUtility.GetPropertyInfo(typeof(ColorBlock), "disabledColor") is PropertyInfo disa && disa.CanWrite)
_disabledColorProp = disa;
}
try
@ -210,6 +214,14 @@ namespace UnityExplorer.Core.Runtime.Il2Cpp
else if (ReflectionUtility.GetFieldInfo(typeof(ColorBlock), "m_PressedColor") is FieldInfo fi)
fi.SetValue(boxed, (Color)pressed);
}
if (disabled != null)
{
if (_disabledColorProp != null)
_disabledColorProp.SetValue(boxed, (Color)disabled);
else if (ReflectionUtility.GetFieldInfo(typeof(ColorBlock), "m_DisabledColor") is FieldInfo fi)
fi.SetValue(boxed, (Color)disabled);
}
}
catch (Exception ex)
{

View File

@ -86,7 +86,8 @@ namespace UnityExplorer.Core.Runtime.Mono
return scene.rootCount;
}
public override void SetColorBlock(Selectable selectable, Color? normal = null, Color? highlighted = null, Color? pressed = null)
public override void SetColorBlock(Selectable selectable, Color? normal = null, Color? highlighted = null, Color? pressed = null,
Color? disabled = null)
{
var colors = selectable.colors;
@ -99,6 +100,9 @@ namespace UnityExplorer.Core.Runtime.Mono
if (pressed != null)
colors.pressedColor = (Color)pressed;
if (disabled != null)
colors.disabledColor = (Color)disabled;
SetColorBlock(selectable, colors);
}

View File

@ -64,7 +64,8 @@ namespace UnityExplorer
public abstract void SetColorBlock(Selectable selectable, ColorBlock colors);
public abstract void SetColorBlock(Selectable selectable, Color? normal = null, Color? highlighted = null, Color? pressed = null);
public abstract void SetColorBlock(Selectable selectable, Color? normal = null, Color? highlighted = null, Color? pressed = null,
Color? disabled = null);
public virtual void FindSingleton(string[] s_instanceNames, Type type, BindingFlags flags, List<object> instances)
{

View File

@ -1,4 +1,5 @@
using System;
using System.Collections;
using System.IO;
using UnityEngine;
using UnityExplorer.Core.Config;
@ -13,7 +14,7 @@ namespace UnityExplorer
public class ExplorerCore
{
public const string NAME = "UnityExplorer";
public const string VERSION = "3.3.11";
public const string VERSION = "3.3.15";
public const string AUTHOR = "Sinai";
public const string GUID = "com.sinai.unityexplorer";
@ -44,10 +45,24 @@ namespace UnityExplorer
InputManager.Init();
UIManager.Init();
Log($"{NAME} {VERSION} initialized.");
RuntimeProvider.Instance.StartCoroutine(SetupCoroutine());
}
// Do a delayed setup so that objects aren't destroyed instantly.
// This can happen for a multitude of reasons.
// Default delay is 1 second which is usually enough.
private static IEnumerator SetupCoroutine()
{
float f = Time.realtimeSinceStartup;
float delay = ConfigManager.Startup_Delay_Time.Value;
while (Time.realtimeSinceStartup - f < delay)
yield return null;
Log($"Creating UI, after delay of {delay} second(s).");
UIManager.Init();
//InspectorManager.Instance.Inspect(typeof(TestClass));
}

View File

@ -21,13 +21,9 @@ namespace UnityExplorer.Loader.ML
{
prefCategory = MelonPreferences.CreateCategory(CTG_NAME, $"{CTG_NAME} Settings");
try
{
// TEMPORARY - JUST REQUIRED UNTIL ML 0.3.1 RELEASED
MelonPreferences.Mapper.RegisterMapper(KeycodeReader, KeycodeWriter);
MelonPreferences.Mapper.RegisterMapper(MenuPagesReader, MenuPagesWriter);
}
catch { }
// temporary until melonloader 0.3.1 released
try { MelonPreferences.Mapper.RegisterMapper(KeycodeReader, KeycodeWriter); } catch { }
try { MelonPreferences.Mapper.RegisterMapper(MenuPagesReader, MenuPagesWriter); } catch { }
}
public override void LoadConfig()

View File

@ -199,23 +199,10 @@ The following helper methods are available:
InputField.onValueChanged.AddListener((string s) => { OnInputChanged(s); });
}
internal static bool IsUserCopyPasting()
{
return (InputManager.GetKey(KeyCode.LeftControl) || InputManager.GetKey(KeyCode.RightControl))
&& InputManager.GetKeyDown(KeyCode.V);
}
public void UpdateConsole()
{
if (s_copyPasteBuffer != null)
{
if (!IsUserCopyPasting())
{
OnInputChanged(s_copyPasteBuffer);
s_copyPasteBuffer = null;
}
}
if (Time.time > s_timeOfLastInternalSet)
Writing = false;
if (EnableCtrlRShortcut)
{
@ -274,6 +261,8 @@ The following helper methods are available:
public void UseAutocomplete(string suggestion)
{
Writing = true;
string input = InputField.text;
input = input.Insert(m_lastCaretPos, suggestion);
InputField.text = input;
@ -288,20 +277,32 @@ The following helper methods are available:
AutoCompleter.ClearAutocompletes();
}
internal static string s_copyPasteBuffer;
private static float s_timeOfLastUpdate;
private static bool Writing
{
get => s_writing;
set
{
if (value)
s_timeOfLastInternalSet = Time.time;
s_writing = value;
}
}
private static bool s_writing;
private static float s_timeOfLastInternalSet;
public void OnInputChanged(string newText, bool forceUpdate = false)
{
if (IsUserCopyPasting())
{
//Console.WriteLine("Copy+Paste detected!");
s_copyPasteBuffer = newText;
if (!Writing && Time.time <= s_timeOfLastUpdate)
return;
}
s_timeOfLastUpdate = Time.time;
if (EnableAutoIndent)
UpdateIndent(newText);
Writing = true;
if (!forceUpdate && string.IsNullOrEmpty(newText))
inputHighlightText.text = string.Empty;
else
@ -378,6 +379,8 @@ The following helper methods are available:
private void AutoIndentCaret()
{
Writing = true;
if (CurrentIndent > 0)
{
string indent = GetAutoIndentTab(CurrentIndent);