Remove arbitrary static restriction on class search

This commit is contained in:
Sinai 2021-07-02 17:53:12 +10:00
parent 7ff508b874
commit 601567f9d2
2 changed files with 7 additions and 9 deletions

View File

@ -53,8 +53,8 @@ namespace UnityExplorer.ObjectExplorer
if (m_context == SearchContext.Singleton) if (m_context == SearchContext.Singleton)
currentResults = SearchProvider.SingletonSearch(nameInputField.Text); currentResults = SearchProvider.SingletonSearch(nameInputField.Text);
else if (m_context == SearchContext.StaticClass) else if (m_context == SearchContext.Class)
currentResults = SearchProvider.StaticClassSearch(nameInputField.Text); currentResults = SearchProvider.ClassSearch(nameInputField.Text);
else else
{ {
string compType = ""; string compType = "";
@ -130,7 +130,7 @@ namespace UnityExplorer.ObjectExplorer
if (!cachedCellTexts.ContainsKey(index)) if (!cachedCellTexts.ContainsKey(index))
{ {
string text; string text;
if (m_context == SearchContext.StaticClass) if (m_context == SearchContext.Class)
text = SignatureHighlighter.Parse(currentResults[index] as Type, true); text = SignatureHighlighter.Parse(currentResults[index] as Type, true);
else else
text = ToStringUtility.ToStringWithType(currentResults[index], currentResults[index]?.GetActualType()); text = ToStringUtility.ToStringWithType(currentResults[index], currentResults[index]?.GetActualType());
@ -143,7 +143,7 @@ namespace UnityExplorer.ObjectExplorer
private void OnCellClicked(int dataIndex) private void OnCellClicked(int dataIndex)
{ {
if (m_context == SearchContext.StaticClass) if (m_context == SearchContext.Class)
InspectorManager.Inspect(currentResults[dataIndex] as Type); InspectorManager.Inspect(currentResults[dataIndex] as Type);
else else
InspectorManager.Inspect(currentResults[dataIndex]); InspectorManager.Inspect(currentResults[dataIndex]);

View File

@ -13,9 +13,8 @@ namespace UnityExplorer.ObjectExplorer
public enum SearchContext public enum SearchContext
{ {
UnityObject, UnityObject,
// GameObject,
Singleton, Singleton,
StaticClass Class
} }
public enum ChildFilter public enum ChildFilter
@ -134,7 +133,7 @@ namespace UnityExplorer.ObjectExplorer
return results; return results;
} }
internal static List<object> StaticClassSearch(string input) internal static List<object> ClassSearch(string input)
{ {
var list = new List<object>(); var list = new List<object>();
@ -144,11 +143,10 @@ namespace UnityExplorer.ObjectExplorer
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
{ {
foreach (var type in asm.TryGetTypes().Where(it => it.IsSealed && it.IsAbstract)) foreach (var type in asm.TryGetTypes())
{ {
if (!string.IsNullOrEmpty(nameFilter) && !type.FullName.ContainsIgnoreCase(nameFilter)) if (!string.IsNullOrEmpty(nameFilter) && !type.FullName.ContainsIgnoreCase(nameFilter))
continue; continue;
list.Add(type); list.Add(type);
} }
} }