From d4fbc89158fdf550aed7041c03cd8451d0d7467f Mon Sep 17 00:00:00 2001 From: Sinai <49360850+sinai-dev@users.noreply.github.com> Date: Sun, 6 Feb 2022 04:50:52 +1100 Subject: [PATCH] Use ReflectionUtility.AllTypes when doing class search to include static classes --- src/ObjectExplorer/ObjectSearch.cs | 8 +++++++- src/UI/Widgets/AutoComplete/TypeCompleter.cs | 11 ++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/ObjectExplorer/ObjectSearch.cs b/src/ObjectExplorer/ObjectSearch.cs index 0ebb48a..ca29039 100644 --- a/src/ObjectExplorer/ObjectSearch.cs +++ b/src/ObjectExplorer/ObjectSearch.cs @@ -99,7 +99,13 @@ namespace UnityExplorer.ObjectExplorer nameInputRow.SetActive(context == SearchContext.UnityObject); - typeAutocompleter.BaseType = context == SearchContext.UnityObject ? typeof(UnityEngine.Object) : typeof(object); + if (context == SearchContext.Class) + typeAutocompleter.AllTypes = true; + else + { + typeAutocompleter.BaseType = context == SearchContext.UnityObject ? typeof(UnityEngine.Object) : typeof(object); + typeAutocompleter.AllTypes = false; + } typeAutocompleter.CacheTypes(); } diff --git a/src/UI/Widgets/AutoComplete/TypeCompleter.cs b/src/UI/Widgets/AutoComplete/TypeCompleter.cs index 97ff982..13073a4 100644 --- a/src/UI/Widgets/AutoComplete/TypeCompleter.cs +++ b/src/UI/Widgets/AutoComplete/TypeCompleter.cs @@ -25,6 +25,8 @@ namespace UnityExplorer.UI.Widgets.AutoComplete public Type BaseType { get; set; } public Type[] GenericConstraints { get; set; } + public bool AllTypes { get; set; } + private readonly bool allowAbstract; private readonly bool allowEnum; @@ -58,7 +60,14 @@ namespace UnityExplorer.UI.Widgets.AutoComplete public void CacheTypes() { - allowedTypes = ReflectionUtility.GetImplementationsOf(BaseType, allowAbstract, allowEnum, false); + if (!AllTypes) + allowedTypes = ReflectionUtility.GetImplementationsOf(BaseType, allowAbstract, allowEnum, false); + else + { + allowedTypes = new(); + foreach (var entry in ReflectionUtility.AllTypes) + allowedTypes.Add(entry.Value as Type); + } } public void OnSuggestionClicked(Suggestion suggestion)