mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-03 20:12:33 +08:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
7386eca0c2 | |||
97325a5f3a | |||
82e52de557 |
@ -16,7 +16,7 @@ namespace UnityExplorer
|
||||
public class ExplorerCore
|
||||
{
|
||||
public const string NAME = "UnityExplorer";
|
||||
public const string VERSION = "3.1.0";
|
||||
public const string VERSION = "3.1.1";
|
||||
public const string AUTHOR = "Sinai";
|
||||
public const string GUID = "com.sinai.unityexplorer";
|
||||
public const string EXPLORER_FOLDER = @"Mods\UnityExplorer";
|
||||
|
@ -111,8 +111,11 @@ namespace UnityExplorer.Inspectors.GameObjects
|
||||
internal static void OnCompToggleClicked(int index, bool value)
|
||||
{
|
||||
var comp = s_compShortlist[index];
|
||||
|
||||
#if CPP
|
||||
comp.TryCast<Behaviour>().enabled = value;
|
||||
#else
|
||||
(comp as Behaviour).enabled = value;
|
||||
#endif
|
||||
}
|
||||
|
||||
internal static void OnCompListObjectClicked(int index)
|
||||
|
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
//using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
@ -51,8 +50,6 @@ namespace UnityExplorer.UI.Modules
|
||||
private SceneFilter m_sceneFilter;
|
||||
private ChildFilter m_childFilter;
|
||||
|
||||
internal bool m_isStaticClassSearching;
|
||||
|
||||
// ui elements
|
||||
|
||||
private Text m_resultCountText;
|
||||
@ -248,12 +245,15 @@ namespace UnityExplorer.UI.Modules
|
||||
UnityObjectSearch();
|
||||
|
||||
RefreshResultList();
|
||||
|
||||
if (m_results.Length > 0)
|
||||
m_resultCountText.text = $"{m_results.Length} Results";
|
||||
else
|
||||
m_resultCountText.text = "No results...";
|
||||
}
|
||||
|
||||
internal void StaticClassSearch()
|
||||
{
|
||||
m_isStaticClassSearching = true;
|
||||
|
||||
var list = new List<Type>();
|
||||
|
||||
var nameFilter = "";
|
||||
@ -274,16 +274,30 @@ namespace UnityExplorer.UI.Modules
|
||||
m_results = list.ToArray();
|
||||
}
|
||||
|
||||
internal string[] s_instanceNames = new string[]
|
||||
{
|
||||
"m_instance",
|
||||
"m_Instance",
|
||||
"s_instance",
|
||||
"s_Instance",
|
||||
"_instance",
|
||||
"_Instance",
|
||||
"instance",
|
||||
"Instance",
|
||||
"<Instance>k__BackingField",
|
||||
"<instance>k__BackingField",
|
||||
};
|
||||
|
||||
private void SingletonSearch()
|
||||
{
|
||||
m_isStaticClassSearching = false;
|
||||
|
||||
var instances = new List<object>();
|
||||
|
||||
var nameFilter = "";
|
||||
if (!string.IsNullOrEmpty(m_nameInput.text))
|
||||
nameFilter = m_nameInput.text.ToLower();
|
||||
|
||||
var flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static;
|
||||
|
||||
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
|
||||
{
|
||||
// All non-static classes
|
||||
@ -293,31 +307,36 @@ namespace UnityExplorer.UI.Modules
|
||||
{
|
||||
if (!string.IsNullOrEmpty(nameFilter) && !type.FullName.ToLower().Contains(nameFilter))
|
||||
continue;
|
||||
|
||||
// First look for an "Instance" Property
|
||||
if (type.GetProperty("Instance", ReflectionHelpers.CommonFlags) is PropertyInfo pi
|
||||
&& pi.CanRead
|
||||
&& pi.GetGetMethod(true).IsStatic)
|
||||
#if CPP
|
||||
// Only look for Properties in IL2CPP, not for Mono.
|
||||
PropertyInfo pi;
|
||||
foreach (var name in s_instanceNames)
|
||||
{
|
||||
pi = type.GetProperty(name, flags);
|
||||
if (pi != null)
|
||||
{
|
||||
var instance = pi.GetValue(null, null);
|
||||
if (instance != null)
|
||||
instances.Add(instance);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise, look for a typical Instance backing field.
|
||||
instances.Add(instance);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// Look for a typical Instance backing field.
|
||||
FieldInfo fi;
|
||||
fi = type.GetField("m_instance", ReflectionHelpers.CommonFlags);
|
||||
if (fi == null)
|
||||
fi = type.GetField("s_instance", ReflectionHelpers.CommonFlags);
|
||||
if (fi == null)
|
||||
fi = type.GetField("_instance", ReflectionHelpers.CommonFlags);
|
||||
if (fi == null)
|
||||
fi = type.GetField("instance", ReflectionHelpers.CommonFlags);
|
||||
|
||||
if (fi != null && fi.IsStatic)
|
||||
foreach (var name in s_instanceNames)
|
||||
{
|
||||
fi = type.GetField(name, flags);
|
||||
if (fi != null)
|
||||
{
|
||||
var instance = fi.GetValue(null);
|
||||
if (instance != null)
|
||||
{
|
||||
instances.Add(instance);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -330,8 +349,6 @@ namespace UnityExplorer.UI.Modules
|
||||
|
||||
internal void UnityObjectSearch()
|
||||
{
|
||||
m_isStaticClassSearching = false;
|
||||
|
||||
Type searchType = null;
|
||||
switch (m_context)
|
||||
{
|
||||
@ -444,11 +461,6 @@ namespace UnityExplorer.UI.Modules
|
||||
}
|
||||
|
||||
m_results = results.ToArray();
|
||||
|
||||
if (m_results.Length > 0)
|
||||
m_resultCountText.text = $"{m_results.Length} Results";
|
||||
else
|
||||
m_resultCountText.text = "No results...";
|
||||
}
|
||||
|
||||
private void OnResultPageTurn()
|
||||
|
@ -46,6 +46,9 @@ namespace UnityExplorer.UI
|
||||
SearchPage.Instance?.OnSceneChange();
|
||||
}
|
||||
|
||||
#if CPP
|
||||
internal static float s_timeOfLastClick;
|
||||
#endif
|
||||
public static void Update()
|
||||
{
|
||||
MainMenu.Instance?.Update();
|
||||
@ -62,9 +65,19 @@ namespace UnityExplorer.UI
|
||||
var evt = InputManager.InputPointerEvent;
|
||||
if (evt != null)
|
||||
{
|
||||
if (Time.realtimeSinceStartup - s_timeOfLastClick > 0.1f)
|
||||
{
|
||||
s_timeOfLastClick = Time.realtimeSinceStartup;
|
||||
|
||||
if (!evt.eligibleForClick && evt.selectedObject)
|
||||
evt.eligibleForClick = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (evt.eligibleForClick)
|
||||
evt.eligibleForClick = false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user