mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-09-20 13:36:01 +08:00
Fix bug in ForceUnlockCursor, fix mistake in Reflection Inspector, reduced amount casting with Reflection Inspector
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Explorer.Helpers;
|
using Explorer.Helpers;
|
||||||
|
using BF = System.Reflection.BindingFlags;
|
||||||
#if ML
|
#if ML
|
||||||
using Harmony;
|
using Harmony;
|
||||||
#else
|
#else
|
||||||
@ -40,8 +41,17 @@ namespace Explorer.UI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get current cursor state and enable cursor
|
// Get current cursor state and enable cursor
|
||||||
m_lastLockMode = Cursor.lockState;
|
try
|
||||||
m_lastVisibleState = Cursor.visible;
|
{
|
||||||
|
//m_lastLockMode = Cursor.lockState;
|
||||||
|
m_lastLockMode = (CursorLockMode?)typeof(Cursor).GetProperty("lockState", BF.Public | BF.Static)?.GetValue(null, null)
|
||||||
|
?? CursorLockMode.None;
|
||||||
|
|
||||||
|
//m_lastVisibleState = Cursor.visible;
|
||||||
|
m_lastVisibleState = (bool?)typeof(Cursor).GetProperty("visible", BF.Public | BF.Static)?.GetValue(null, null)
|
||||||
|
?? false;
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
// Setup Harmony Patches
|
// Setup Harmony Patches
|
||||||
TryPatch("lockState", new HarmonyMethod(typeof(ForceUnlockCursor).GetMethod(nameof(Prefix_set_lockState))), true);
|
TryPatch("lockState", new HarmonyMethod(typeof(ForceUnlockCursor).GetMethod(nameof(Prefix_set_lockState))), true);
|
||||||
|
@ -99,20 +99,20 @@ namespace Explorer.UI.Inspectors
|
|||||||
if (m_typeFilter != MemberTypes.All && m_typeFilter != holder.MemInfo?.MemberType)
|
if (m_typeFilter != MemberTypes.All && m_typeFilter != holder.MemInfo?.MemberType)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// check scope filter
|
|
||||||
if (m_scopeFilter == MemberScopes.Instance)
|
|
||||||
{
|
|
||||||
return !holder.IsStatic;
|
|
||||||
}
|
|
||||||
else if (m_scopeFilter == MemberScopes.Static)
|
|
||||||
{
|
|
||||||
return holder.IsStatic;
|
|
||||||
}
|
|
||||||
|
|
||||||
// hide failed reflection
|
// hide failed reflection
|
||||||
if (!string.IsNullOrEmpty(holder.ReflectionException) && m_hideFailedReflection)
|
if (!string.IsNullOrEmpty(holder.ReflectionException) && m_hideFailedReflection)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// check scope filter
|
||||||
|
if (m_scopeFilter == MemberScopes.Instance && holder.IsStatic)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (m_scopeFilter == MemberScopes.Static && !holder.IsStatic)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// see if we should do name search
|
// see if we should do name search
|
||||||
if (m_search == "" || holder.MemInfo == null)
|
if (m_search == "" || holder.MemInfo == null)
|
||||||
return true;
|
return true;
|
||||||
@ -141,22 +141,6 @@ namespace Explorer.UI.Inspectors
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
object target = Target;
|
|
||||||
string exception = null;
|
|
||||||
|
|
||||||
#if CPP
|
|
||||||
if (!IsStaticInspector && target is Il2CppSystem.Object ilObject)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
target = ilObject.Il2CppCast(declaringType);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
exception = ReflectionHelpers.ExceptionToString(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
foreach (var member in infos)
|
foreach (var member in infos)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -211,17 +195,12 @@ namespace Explorer.UI.Inspectors
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var cached = CacheFactory.GetCacheObject(member, target);
|
var cached = CacheFactory.GetCacheObject(member, Target);
|
||||||
|
|
||||||
if (cached != null)
|
if (cached != null)
|
||||||
{
|
{
|
||||||
cachedSigs.Add(sig);
|
cachedSigs.Add(sig);
|
||||||
list.Add(cached);
|
list.Add(cached);
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(cached.ReflectionException))
|
|
||||||
{
|
|
||||||
cached.ReflectionException = exception;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Explorer.Config;
|
using Explorer.Config;
|
||||||
using Explorer.UI.Inspectors;
|
using Explorer.UI.Inspectors;
|
||||||
|
using Explorer.Helpers;
|
||||||
|
|
||||||
namespace Explorer.UI
|
namespace Explorer.UI
|
||||||
{
|
{
|
||||||
@ -26,7 +27,15 @@ namespace Explorer.UI
|
|||||||
{
|
{
|
||||||
var window = Activator.CreateInstance<T>();
|
var window = Activator.CreateInstance<T>();
|
||||||
|
|
||||||
|
#if CPP
|
||||||
|
if (target is Il2CppSystem.Object ilObject)
|
||||||
|
{
|
||||||
|
target = ilObject.Il2CppCast(ReflectionHelpers.GetActualType(ilObject));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
window.Target = target;
|
window.Target = target;
|
||||||
|
|
||||||
window.windowID = WindowManager.NextWindowID();
|
window.windowID = WindowManager.NextWindowID();
|
||||||
window.m_rect = WindowManager.GetNewWindowRect();
|
window.m_rect = WindowManager.GetNewWindowRect();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user