mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-01-03 16:13:25 +08:00
Bump UniverseLib, fix C# Console issues, add Stop helper
This commit is contained in:
parent
b9a3ab7439
commit
9e49f09a79
@ -19,6 +19,7 @@ using UniverseLib;
|
||||
using UniverseLib.UI.Models;
|
||||
using UniverseLib.Utility;
|
||||
using HarmonyLib;
|
||||
using UniverseLib.Runtime;
|
||||
|
||||
namespace UnityExplorer.CSConsole
|
||||
{
|
||||
@ -61,6 +62,8 @@ namespace UnityExplorer.CSConsole
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
InitEventSystemPropertyHandlers();
|
||||
|
||||
// Make sure console is supported on this platform
|
||||
try
|
||||
{
|
||||
@ -384,37 +387,55 @@ namespace UnityExplorer.CSConsole
|
||||
RuntimeHelper.StartCoroutine(SetCaretCoroutine(caretPosition));
|
||||
}
|
||||
|
||||
internal static MemberInfo selectionGuardMemberInfo;
|
||||
|
||||
internal static MemberInfo GetSelectionGuardMemberInfo()
|
||||
static void InitEventSystemPropertyHandlers()
|
||||
{
|
||||
if (selectionGuardMemberInfo != null)
|
||||
return selectionGuardMemberInfo;
|
||||
try
|
||||
{
|
||||
foreach (var member in typeof(EventSystem).GetMembers(AccessTools.all))
|
||||
{
|
||||
if (member.Name == "m_CurrentSelected")
|
||||
{
|
||||
Type backingType;
|
||||
if (member.MemberType == MemberTypes.Property)
|
||||
backingType = (member as PropertyInfo).PropertyType;
|
||||
else
|
||||
backingType = (member as FieldInfo).FieldType;
|
||||
|
||||
if (AccessTools.Property(typeof(EventSystem), "m_SelectionGuard") is PropertyInfo pi_m_SelectionGuard)
|
||||
return selectionGuardMemberInfo = pi_m_SelectionGuard;
|
||||
|
||||
if (AccessTools.Property(typeof(EventSystem), "m_selectionGuard") is PropertyInfo pi_m_selectionGuard)
|
||||
return selectionGuardMemberInfo = pi_m_selectionGuard;
|
||||
|
||||
if (AccessTools.Field(typeof(EventSystem), "m_SelectionGuard") is FieldInfo fi_m_SelectionGuard)
|
||||
return selectionGuardMemberInfo = fi_m_SelectionGuard;
|
||||
|
||||
return selectionGuardMemberInfo = AccessTools.Field(typeof(EventSystem), "m_selectionGuard");
|
||||
usingEventSystemDictionaryMembers = ReflectionUtility.IsDictionary(backingType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ExplorerCore.LogWarning($"Exception checking EventSystem property backing type: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
internal static void SetSelectionGuard(EventSystem instance, bool value)
|
||||
static bool usingEventSystemDictionaryMembers;
|
||||
|
||||
static readonly AmbiguousMemberHandler<EventSystem, GameObject> m_CurrentSelected_Handler_Normal = new("m_CurrentSelected", "m_currentSelected");
|
||||
static readonly AmbiguousMemberHandler<EventSystem, Dictionary<int, GameObject>> m_CurrentSelected_Handler_Dictionary = new("m_CurrentSelected", "m_currentSelected");
|
||||
|
||||
static readonly AmbiguousMemberHandler<EventSystem, bool> m_SelectionGuard_Handler_Normal = new("m_SelectionGuard", "m_selectionGuard");
|
||||
static readonly AmbiguousMemberHandler<EventSystem, Dictionary<int, bool>> m_SelectionGuard_Handler_Dictionary = new("m_SelectionGuard", "m_selectionGuard");
|
||||
|
||||
static void SetCurrentSelectedGameObject(EventSystem instance, GameObject value)
|
||||
{
|
||||
var member = GetSelectionGuardMemberInfo();
|
||||
if (member == null)
|
||||
return;
|
||||
if (member is PropertyInfo pi)
|
||||
{
|
||||
pi.SetValue(instance, value, null);
|
||||
return;
|
||||
instance.SetSelectedGameObject(value);
|
||||
|
||||
if (usingEventSystemDictionaryMembers)
|
||||
m_CurrentSelected_Handler_Dictionary.GetValue(instance)[0] = value;
|
||||
else
|
||||
m_CurrentSelected_Handler_Normal.SetValue(instance, value);
|
||||
}
|
||||
var fi = member as FieldInfo;
|
||||
fi.SetValue(instance, value);
|
||||
|
||||
static void SetSelectionGuard(EventSystem instance, bool value)
|
||||
{
|
||||
if (usingEventSystemDictionaryMembers)
|
||||
m_SelectionGuard_Handler_Dictionary.GetValue(instance)[0] = value;
|
||||
else
|
||||
m_SelectionGuard_Handler_Normal.SetValue(instance, value);
|
||||
}
|
||||
|
||||
private static IEnumerator SetCaretCoroutine(int caretPosition)
|
||||
@ -423,7 +444,7 @@ namespace UnityExplorer.CSConsole
|
||||
color.a = 0f;
|
||||
Input.Component.selectionColor = color;
|
||||
|
||||
try { CursorUnlocker.CurrentEventSystem.m_CurrentSelected = null; }
|
||||
try { SetCurrentSelectedGameObject(CursorUnlocker.CurrentEventSystem, null); }
|
||||
catch (Exception ex) { ExplorerCore.Log($"Failed removing selected object: {ex}"); }
|
||||
|
||||
yield return null; // ~~~~~~~ YIELD FRAME ~~~~~~~~~
|
||||
@ -431,7 +452,7 @@ namespace UnityExplorer.CSConsole
|
||||
try { SetSelectionGuard(CursorUnlocker.CurrentEventSystem, false); }
|
||||
catch (Exception ex) { ExplorerCore.Log($"Failed setting selection guard: {ex}"); }
|
||||
|
||||
try { CursorUnlocker.CurrentEventSystem.SetSelectedGameObject(Input.GameObject, null); }
|
||||
try { SetCurrentSelectedGameObject(CursorUnlocker.CurrentEventSystem, Input.GameObject); }
|
||||
catch (Exception ex) { ExplorerCore.Log($"Failed setting selected gameobject: {ex}"); }
|
||||
|
||||
yield return null; // ~~~~~~~ YIELD FRAME ~~~~~~~~~
|
||||
@ -695,7 +716,8 @@ var x = 5;
|
||||
* Log(obj); - prints a message to the console log
|
||||
* Inspect(obj); - inspect the object with the Inspector
|
||||
* Inspect(someType); - inspect a Type with static reflection
|
||||
* Start(enumerator); - starts the IEnumerator as a Coroutine
|
||||
* Start(enumerator); - Coroutine, starts the IEnumerator as a Coroutine, and returns the Coroutine.
|
||||
* Stop(coroutine); - stop the Coroutine ONLY if it was started with Start(ienumerator).
|
||||
* Copy(obj); - copies the object to the UnityExplorer Clipboard
|
||||
* Paste(); - System.Object, the contents of the Clipboard.
|
||||
* GetUsing(); - prints the current using directives to the console log
|
||||
|
@ -29,9 +29,12 @@ namespace UnityExplorer.CSConsole
|
||||
public static void Inspect(Type type)
|
||||
=> InspectorManager.Inspect(type);
|
||||
|
||||
public static void Start(IEnumerator ienumerator)
|
||||
public static Coroutine Start(IEnumerator ienumerator)
|
||||
=> RuntimeHelper.StartCoroutine(ienumerator);
|
||||
|
||||
public static void Stop(Coroutine coro)
|
||||
=> RuntimeHelper.StopCoroutine(coro);
|
||||
|
||||
public static void Copy(object obj)
|
||||
=> ClipboardPanel.Copy(obj);
|
||||
|
||||
|
@ -175,13 +175,13 @@
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="UniverseLib.Mono">
|
||||
<HintPath>packages\UniverseLib.1.2.5\lib\net35\UniverseLib.Mono.dll</HintPath>
|
||||
<HintPath>packages\UniverseLib.1.2.6\lib\net35\UniverseLib.Mono.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<!-- Il2Cpp refs -->
|
||||
<ItemGroup Condition="'$(IsCpp)'=='true'">
|
||||
<Reference Include="UniverseLib.IL2CPP">
|
||||
<HintPath>packages\UniverseLib.1.2.5\lib\net472\UniverseLib.IL2CPP.dll</HintPath>
|
||||
<HintPath>packages\UniverseLib.1.2.6\lib\net472\UniverseLib.IL2CPP.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnhollowerBaseLib, Version=0.4.22.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Il2CppAssemblyUnhollower.BaseLib.0.4.22\lib\net472\UnhollowerBaseLib.dll</HintPath>
|
||||
|
@ -6,6 +6,6 @@
|
||||
<package id="ILRepack.Lib.MSBuild.Task" version="2.0.18.2" targetFramework="net35" />
|
||||
<package id="Mono.Cecil" version="0.10.4" targetFramework="net35" />
|
||||
<package id="Samboy063.Tomlet" version="3.1.3" targetFramework="net472" />
|
||||
<package id="UniverseLib" version="1.2.5" targetFramework="net35" />
|
||||
<package id="UniverseLib" version="1.2.6" targetFramework="net35" />
|
||||
<package id="UniverseLib.Analyzers" version="1.0.3" targetFramework="net35" developmentDependency="true" />
|
||||
</packages>
|
Loading…
x
Reference in New Issue
Block a user