Make AutoCompleter a global widget which anything can use, add support to object search for it

This commit is contained in:
Sinai 2021-04-24 04:03:33 +10:00
parent 5f2f3fe1c6
commit bda286ddae
8 changed files with 246 additions and 150 deletions

View File

@ -25,6 +25,7 @@ namespace UnityExplorer.UI
CSConsole, CSConsole,
Options, Options,
ConsoleLog, ConsoleLog,
AutoCompleter
} }
public static GameObject CanvasRoot { get; private set; } public static GameObject CanvasRoot { get; private set; }
@ -33,16 +34,20 @@ namespace UnityExplorer.UI
// panels // panels
internal static GameObject PanelHolder { get; private set; } internal static GameObject PanelHolder { get; private set; }
public static ObjectExplorer Explorer { get; private set; } public static ObjectExplorer Explorer { get; private set; }
public static InspectorTest Inspector { get; private set; } public static InspectorTest Inspector { get; private set; }
public static AutoCompleter AutoCompleter { get; private set; }
private static readonly Dictionary<Panels, Button> navButtonDict = new Dictionary<Panels, Button>();
internal static readonly Color navButtonEnabledColor = new Color(0.2f, 0.4f, 0.28f);
internal static readonly Color navButtonDisabledColor = new Color(0.25f, 0.25f, 0.25f);
// bundle assets // bundle assets
internal static Font ConsoleFont { get; private set; } internal static Font ConsoleFont { get; private set; }
internal static Shader BackupShader { get; private set; } internal static Shader BackupShader { get; private set; }
internal static readonly Color navButtonEnabledColor = new Color(0.2f, 0.4f, 0.28f); // main menu toggle
internal static readonly Color navButtonDisabledColor = new Color(0.25f, 0.25f, 0.25f);
public static bool ShowMenu public static bool ShowMenu
{ {
get => s_showMenu; get => s_showMenu;
@ -58,29 +63,6 @@ namespace UnityExplorer.UI
} }
public static bool s_showMenu = true; public static bool s_showMenu = true;
internal static void InitUI()
{
LoadBundle();
UIFactory.Init();
CreateRootCanvas();
CreateTopNavBar();
AutoCompleter.ConstructUI();
//InspectUnderMouse.ConstructUI();
Explorer = new ObjectExplorer();
Explorer.ConstructUI(CanvasRoot);
Inspector = new InspectorTest();
Inspector.ConstructUI(CanvasRoot);
ShowMenu = !ConfigManager.Hide_On_Startup.Value;
ExplorerCore.Log("UI initialized.");
}
public static void Update() public static void Update()
{ {
if (!CanvasRoot) if (!CanvasRoot)
@ -111,6 +93,63 @@ namespace UnityExplorer.UI
AutoCompleter.Update(); AutoCompleter.Update();
} }
public static UIPanel GetPanel(Panels panel)
{
switch (panel)
{
case Panels.ObjectExplorer:
return Explorer;
case Panels.Inspector:
return Inspector;
case Panels.AutoCompleter:
return AutoCompleter;
default:
throw new NotImplementedException($"TODO GetPanel: {panel}");
}
}
public static void TogglePanel(Panels panel)
{
var uiPanel = GetPanel(panel);
SetPanelActive(panel, !uiPanel.Enabled);
}
public static void SetPanelActive(Panels panel, bool active)
{
GetPanel(panel).SetActive(active);
if (navButtonDict.ContainsKey(panel))
{
var color = active ? navButtonEnabledColor : navButtonDisabledColor;
RuntimeProvider.Instance.SetColorBlock(navButtonDict[panel], color, color * 1.2f);
}
}
internal static void InitUI()
{
LoadBundle();
UIFactory.Init();
CreateRootCanvas();
CreateTopNavBar();
AutoCompleter = new AutoCompleter();
AutoCompleter.ConstructUI();
//InspectUnderMouse.ConstructUI();
Explorer = new ObjectExplorer();
Explorer.ConstructUI();
Inspector = new InspectorTest();
Inspector.ConstructUI();
ShowMenu = !ConfigManager.Hide_On_Startup.Value;
ExplorerCore.Log("UI initialized.");
}
private static void CreateRootCanvas() private static void CreateRootCanvas()
{ {
CanvasRoot = new GameObject("ExplorerCanvas"); CanvasRoot = new GameObject("ExplorerCanvas");
@ -145,32 +184,6 @@ namespace UnityExplorer.UI
PanelHolder.transform.SetAsFirstSibling(); PanelHolder.transform.SetAsFirstSibling();
} }
public static UIPanel GetPanel(Panels panel)
{
switch (panel)
{
case Panels.ObjectExplorer:
return Explorer;
case Panels.Inspector:
return Inspector;
default:
throw new NotImplementedException($"TODO GetPanel: {panel}");
}
}
public static void TogglePanel(Panels panel)
{
var uiPanel = GetPanel(panel);
SetPanelActive(panel, !uiPanel.Enabled);
}
public static void SetPanelActive(Panels panel, bool active)
{
GetPanel(panel).SetActive(active);
var color = active ? navButtonEnabledColor : navButtonDisabledColor;
RuntimeProvider.Instance.SetColorBlock(navButtonDict[panel], color, color * 1.2f);
}
public static void CreateTopNavBar() public static void CreateTopNavBar()
{ {
var panel = UIFactory.CreateUIObject("MainNavbar", CanvasRoot); var panel = UIFactory.CreateUIObject("MainNavbar", CanvasRoot);
@ -200,8 +213,6 @@ namespace UnityExplorer.UI
new Color(0.81f, 0.25f, 0.2f), new Color(0.6f, 0.18f, 0.16f)); new Color(0.81f, 0.25f, 0.2f), new Color(0.6f, 0.18f, 0.16f));
} }
private static readonly Dictionary<Panels, Button> navButtonDict = new Dictionary<Panels, Button>();
private static void CreateNavButton(GameObject navbar, Panels panel, string label) private static void CreateNavButton(GameObject navbar, Panels panel, string label)
{ {
var button = UIFactory.CreateButton(navbar, $"Button_{panel}", label); var button = UIFactory.CreateButton(navbar, $"Button_{panel}", label);

View File

@ -2,6 +2,7 @@
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using UnityEngine; using UnityEngine;
using UnityExplorer.Core.Runtime;
namespace UnityExplorer.UI.Utility namespace UnityExplorer.UI.Utility
{ {
@ -47,6 +48,8 @@ namespace UnityExplorer.UI.Utility
if (type == null) if (type == null)
throw new ArgumentNullException("type"); throw new ArgumentNullException("type");
//type = ReflectionProvider.Instance.GetDeobfuscatedType(type);
string ret = ""; string ret = "";
if (type.IsGenericParameter || (type.HasElementType && type.GetElementType().IsGenericParameter)) if (type.IsGenericParameter || (type.HasElementType && type.GetElementType().IsGenericParameter))
@ -91,8 +94,10 @@ namespace UnityExplorer.UI.Utility
return ret; return ret;
} }
private static string HighlightTypeName(Type type) public static string HighlightTypeName(Type type)
{ {
//type = RuntimeProvider.Instance.Reflection.GetDeobfuscatedType(type);
var typeName = type.Name; var typeName = type.Name;
var gArgs = type.GetGenericArguments(); var gArgs = type.GetGenericArguments();
@ -121,7 +126,7 @@ namespace UnityExplorer.UI.Utility
return typeName; return typeName;
} }
private static string ParseGenericArgs(Type[] gArgs, bool allGeneric = false) public static string ParseGenericArgs(Type[] gArgs, bool allGeneric = false)
{ {
if (gArgs.Length < 1) if (gArgs.Length < 1)
return ""; return "";
@ -146,7 +151,7 @@ namespace UnityExplorer.UI.Utility
return args + ">"; return args + ">";
} }
private static string GetMemberInfoColor(MemberInfo memberInfo, out bool isStatic) public static string GetMemberInfoColor(MemberInfo memberInfo, out bool isStatic)
{ {
string memberColor = ""; string memberColor = "";
isStatic = false; isStatic = false;

View File

@ -14,44 +14,38 @@ namespace UnityExplorer.UI.Utility
internal static Dictionary<Type, MethodInfo> toStringMethods = new Dictionary<Type, MethodInfo>(); internal static Dictionary<Type, MethodInfo> toStringMethods = new Dictionary<Type, MethodInfo>();
internal static Dictionary<Type, MethodInfo> toStringFormattedMethods = new Dictionary<Type, MethodInfo>(); internal static Dictionary<Type, MethodInfo> toStringFormattedMethods = new Dictionary<Type, MethodInfo>();
public static string ToString(object value, Type fallbackType, bool includeNamespace = true, bool includeName = true, bool objectAsType = false) public static string ToString(object value, Type fallbackType, bool includeNamespace = true, bool includeName = true)
{ {
if (value == null && fallbackType == null) if (value == null && fallbackType == null)
return "<null>"; return "<null>";
Type type; Type type = value?.GetActualType() ?? fallbackType;
if (objectAsType)
type = value.TryCast<Type>();
else
type = value?.GetActualType() ?? fallbackType;
var richType = SignatureHighlighter.ParseFullSyntax(type, includeNamespace); var richType = SignatureHighlighter.ParseFullSyntax(type, includeNamespace);
if (objectAsType)
return richType;
if (!includeName) if (!includeName)
return richType; return richType;
if (value.IsNullOrDestroyed()) if (value.IsNullOrDestroyed())
return $"<color=grey>null</color> ({richType})"; {
if (value == null)
return $"<color=grey>[null]</color> ({richType})";
else
return $"<color=red>[Destroyed]</color> ({richType})";
}
// value = value.TryCast(type);
string label; string label;
// Two dirty fixes for TextAsset and EventSystem, which can have very long ToString results. // Two dirty fixes for TextAsset and EventSystem, which can have very long ToString results.
if (value is TextAsset textAsset) if (value is TextAsset textAsset)
{ {
label = textAsset.text; label = $"{textAsset.name} ({richType})";
if (label.Length > 10)
label = $"{label.Substring(0, 10)}...";
label = $"\"{label}\" {textAsset.name} ({richType})";
} }
else if (value is EventSystem) else if (value is EventSystem es)
{ {
label = richType; label = $"{es.name} ({richType})";
} }
else // For everything else... else // For everything else...
{ {
@ -73,6 +67,8 @@ namespace UnityExplorer.UI.Utility
var f3Method = toStringFormattedMethods[type]; var f3Method = toStringFormattedMethods[type];
var stdMethod = toStringMethods[type]; var stdMethod = toStringMethods[type];
value = value.TryCast(type);
string toString; string toString;
if (f3Method != null) if (f3Method != null)
toString = (string)f3Method.Invoke(value, new object[] { "F3" }); toString = (string)f3Method.Invoke(value, new object[] { "F3" });
@ -85,7 +81,7 @@ namespace UnityExplorer.UI.Utility
if (typeName.StartsWith("Il2CppSystem.")) if (typeName.StartsWith("Il2CppSystem."))
typeName = typeName.Substring(6, typeName.Length - 6); typeName = typeName.Substring(6, typeName.Length - 6);
toString = ReflectionProvider.Instance.ProcessTypeNameInString(type, toString, ref typeName); toString = ReflectionProvider.Instance.ProcessTypeFullNameInString(type, toString, ref typeName);
// If the ToString is just the type name, use our syntax highlighted type name instead. // If the ToString is just the type name, use our syntax highlighted type name instead.
if (toString == typeName) if (toString == typeName)

View File

@ -11,23 +11,60 @@ using UnityExplorer.UI.Models;
namespace UnityExplorer.UI.Widgets.AutoComplete namespace UnityExplorer.UI.Widgets.AutoComplete
{ {
// todo add a 'close' button if the user wants to manually hide the suggestions box public class AutoCompleter : UIPanel
public static class AutoCompleter
{ {
public static ISuggestionProvider CurrentHandler; // Static
public static GameObject UIRoot => uiRoot; public static AutoCompleter Instance => UIManager.AutoCompleter;
public static GameObject uiRoot;
public static ButtonListSource<Suggestion> dataHandler; // Instance
public static ScrollPool scrollPool;
private static List<Suggestion> suggestions = new List<Suggestion>(); public AutoCompleter()
{
OnPanelsReordered += UIPanel_OnPanelsReordered;
OnClickedOutsidePanels += AutoCompleter_OnClickedOutsidePanels;
}
private static int lastCaretPos; private void AutoCompleter_OnClickedOutsidePanels()
{
if (!this.UIRoot || !this.UIRoot.activeInHierarchy)
return;
public static void Update() if (CurrentHandler != null)
ReleaseOwnership(CurrentHandler);
else
UIRoot.SetActive(false);
}
private void UIPanel_OnPanelsReordered()
{
if (!this.UIRoot || !this.UIRoot.activeInHierarchy)
return;
if (this.UIRoot.transform.GetSiblingIndex() != UIManager.PanelHolder.transform.childCount - 1)
{
if (CurrentHandler != null)
ReleaseOwnership(CurrentHandler);
else
UIRoot.SetActive(false);
}
}
public override string Name => "AutoCompleter";
public override UIManager.Panels PanelType => UIManager.Panels.AutoCompleter;
public override bool CanDrag => false;
public ISuggestionProvider CurrentHandler { get; private set; }
public ButtonListSource<Suggestion> dataHandler;
public ScrollPool scrollPool;
private List<Suggestion> suggestions = new List<Suggestion>();
private int lastCaretPos;
public override void Update()
{ {
if (!UIRoot || !UIRoot.activeSelf) if (!UIRoot || !UIRoot.activeSelf)
return; return;
@ -44,12 +81,12 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
} }
} }
public static void TakeOwnership(ISuggestionProvider provider) public void TakeOwnership(ISuggestionProvider provider)
{ {
CurrentHandler = provider; CurrentHandler = provider;
} }
public static void ReleaseOwnership(ISuggestionProvider provider) public void ReleaseOwnership(ISuggestionProvider provider)
{ {
if (CurrentHandler == null) if (CurrentHandler == null)
return; return;
@ -61,11 +98,11 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
} }
} }
private static List<Suggestion> GetEntries() => suggestions; private List<Suggestion> GetEntries() => suggestions;
private static bool ShouldDisplay(Suggestion data, string filter) => true; private bool ShouldDisplay(Suggestion data, string filter) => true;
public static void SetSuggestions(List<Suggestion> collection) public void SetSuggestions(List<Suggestion> collection)
{ {
suggestions = collection; suggestions = collection;
@ -74,19 +111,19 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
else else
{ {
UIRoot.SetActive(true); UIRoot.SetActive(true);
UIRoot.transform.SetAsLastSibling();
dataHandler.RefreshData(); dataHandler.RefreshData();
scrollPool.Rebuild(); scrollPool.RefreshAndJumpToTop();
//scrollPool.RefreshCells(true);
} }
} }
private static void OnCellClicked(int dataIndex) private void OnCellClicked(int dataIndex)
{ {
var suggestion = suggestions[dataIndex]; var suggestion = suggestions[dataIndex];
CurrentHandler.OnSuggestionClicked(suggestion); CurrentHandler.OnSuggestionClicked(suggestion);
} }
private static void SetCell(ButtonCell<Suggestion> cell, int index) private void SetCell(ButtonCell<Suggestion> cell, int index)
{ {
if (index < 0 || index >= suggestions.Count) if (index < 0 || index >= suggestions.Count)
{ {
@ -98,43 +135,66 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
cell.buttonText.text = suggestion.DisplayText; cell.buttonText.text = suggestion.DisplayText;
} }
private static void UpdatePosition() private void UpdatePosition()
{ {
if (CurrentHandler == null || !CurrentHandler.InputField.isFocused) if (CurrentHandler == null || !CurrentHandler.InputField.isFocused)
return; return;
Vector3 pos;
var input = CurrentHandler.InputField; var input = CurrentHandler.InputField;
var textGen = input.textComponent.cachedTextGenerator; var textGen = input.textComponent.cachedTextGenerator;
int caretPos = lastCaretPos; int caretPos = 0;
caretPos--; if (CurrentHandler.AnchorToCaretPosition)
{
caretPos = lastCaretPos--;
caretPos = Math.Max(0, caretPos); caretPos = Math.Max(0, caretPos);
caretPos = Math.Min(textGen.characters.Count - 1, caretPos); caretPos = Math.Min(textGen.characterCount - 1, caretPos);
}
var pos = textGen.characters[caretPos].cursorPos; pos = textGen.characters[caretPos].cursorPos;
pos = input.transform.TransformPoint(pos); pos = input.transform.TransformPoint(pos);
uiRoot.transform.position = new Vector3(pos.x + 10, pos.y - 20, 0); uiRoot.transform.position = new Vector3(pos.x + 10, pos.y - 20, 0);
this.Dragger.OnEndResize();
} }
public static void ConstructUI() public override void SetDefaultPosAndAnchors()
{ {
var parent = UIManager.CanvasRoot;
dataHandler = new ButtonListSource<Suggestion>(scrollPool, GetEntries, SetCell, ShouldDisplay, OnCellClicked);
scrollPool = UIFactory.CreateScrollPool(parent, "AutoCompleter", out uiRoot, out GameObject scrollContent);
var mainRect = uiRoot.GetComponent<RectTransform>(); var mainRect = uiRoot.GetComponent<RectTransform>();
mainRect.pivot = new Vector2(0f, 1f); mainRect.pivot = new Vector2(0f, 1f);
mainRect.anchorMin = new Vector2(0.45f, 0.45f); mainRect.anchorMin = new Vector2(0, 1);
mainRect.anchorMax = new Vector2(0.65f, 0.6f); mainRect.anchorMax = new Vector2(0, 1);
mainRect.offsetMin = Vector2.zero; mainRect.offsetMin = new Vector2(25, 0);
mainRect.offsetMax = Vector2.zero; mainRect.offsetMax = new Vector2(525, 169);
UIFactory.SetLayoutGroup<VerticalLayoutGroup>(scrollContent, true, false, true, false); }
scrollPool.Initialize(dataHandler, ButtonCell<Suggestion>.CreatePrototypeCell(parent)); public override void ConstructPanelContent()
{
dataHandler = new ButtonListSource<Suggestion>(scrollPool, GetEntries, SetCell, ShouldDisplay, OnCellClicked);
var prototypeCell = ButtonCell<Suggestion>.CreatePrototypeCell(this.content);
prototypeCell.GetComponentInChildren<Text>().supportRichText = true;
scrollPool = UIFactory.CreateScrollPool(this.content, "AutoCompleter", out GameObject scrollObj, out GameObject scrollContent);
scrollPool.Initialize(dataHandler, prototypeCell);
UIFactory.SetLayoutElement(scrollObj, flexibleHeight: 9999);
UIFactory.SetLayoutGroup<VerticalLayoutGroup>(scrollContent, true, false, true, false);
UIRoot.SetActive(false); UIRoot.SetActive(false);
} }
public override void SaveToConfigManager()
{
// not savable
}
public override void LoadSaveData()
{
// not savable
}
} }
} }

View File

@ -10,6 +10,7 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
public interface ISuggestionProvider public interface ISuggestionProvider
{ {
InputField InputField { get; } InputField InputField { get; }
bool AnchorToCaretPosition { get; }
void OnSuggestionClicked(Suggestion suggestion); void OnSuggestionClicked(Suggestion suggestion);
} }

View File

@ -10,18 +10,18 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
public struct Suggestion public struct Suggestion
{ {
public readonly string DisplayText; public readonly string DisplayText;
public readonly string UnderlyingValue;
public readonly string Prefix; public readonly string Prefix;
public readonly string Addition; public readonly string Addition;
public readonly Color TextColor;
public string Full => Prefix + Addition; public string Full => Prefix + Addition;
public Suggestion(string displayText, string prefix, string addition, Color color) public Suggestion(string displayText, string prefix, string addition, string underlyingValue)
{ {
DisplayText = displayText; DisplayText = displayText;
Addition = addition; Addition = addition;
Prefix = prefix; Prefix = prefix;
TextColor = color; UnderlyingValue = underlyingValue;
} }
} }
} }

View File

@ -10,24 +10,26 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
{ {
public class TypeCompleter : ISuggestionProvider public class TypeCompleter : ISuggestionProvider
{ {
private struct CachedType private class CachedType
{ {
public string FilteredName; public string FullNameForFilter;
public string FullNameValue;
public string DisplayName; public string DisplayName;
} }
public Type BaseType { get; } public Type BaseType { get; }
public InputField InputField { get; } public InputField InputField { get; }
public bool AnchorToCaretPosition => false;
public event Action<Suggestion> SuggestionClicked; public event Action<Suggestion> SuggestionClicked;
public void OnSuggestionClicked(Suggestion suggestion) public void OnSuggestionClicked(Suggestion suggestion)
{ {
SuggestionClicked?.Invoke(suggestion); SuggestionClicked?.Invoke(suggestion);
suggestions.Clear(); suggestions.Clear();
AutoCompleter.SetSuggestions(suggestions); AutoCompleter.Instance.SetSuggestions(suggestions);
timeOfLastCheck = Time.time; timeOfLastCheck = Time.time;
InputField.text = suggestion.DisplayText; InputField.text = suggestion.UnderlyingValue;
} }
private readonly List<Suggestion> suggestions = new List<Suggestion>(); private readonly List<Suggestion> suggestions = new List<Suggestion>();
@ -48,16 +50,34 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
inputField.onValueChanged.AddListener(OnInputFieldChanged); inputField.onValueChanged.AddListener(OnInputFieldChanged);
var types = ReflectionUtility.GetImplementationsOf(typeof(UnityEngine.Object), true); var types = ReflectionUtility.GetImplementationsOf(this.BaseType, true, false);
foreach (var type in types.OrderBy(it => it.FullName))
var list = new List<CachedType>();
foreach (var type in types)
{ {
var name = type.FullName; string displayName = Utility.SignatureHighlighter.ParseFullSyntax(type, true);
typeCache.Add(name.ToLower(), new CachedType string fullName = RuntimeProvider.Instance.Reflection.GetDeobfuscatedType(type).FullName;
string filteredName = fullName.ToLower();
list.Add(new CachedType
{ {
DisplayName = name, FullNameValue = fullName,
FilteredName = name.ToLower() FullNameForFilter = filteredName,
DisplayName = displayName,
}); });
} }
list.Sort((CachedType a, CachedType b) => a.FullNameForFilter.CompareTo(b.FullNameForFilter));
foreach (var cache in list)
{
if (typeCache.ContainsKey(cache.FullNameForFilter))
continue;
typeCache.Add(cache.FullNameForFilter, cache);
}
} }
private float timeOfLastCheck; private float timeOfLastCheck;
@ -73,14 +93,14 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
if (string.IsNullOrEmpty(value)) if (string.IsNullOrEmpty(value))
{ {
AutoCompleter.ReleaseOwnership(this); AutoCompleter.Instance.ReleaseOwnership(this);
} }
else else
{ {
GetSuggestions(value); GetSuggestions(value);
AutoCompleter.TakeOwnership(this); AutoCompleter.Instance.TakeOwnership(this);
AutoCompleter.SetSuggestions(suggestions); AutoCompleter.Instance.SetSuggestions(suggestions);
} }
} }
@ -91,28 +111,27 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
var added = new HashSet<string>(); var added = new HashSet<string>();
if (typeCache.TryGetValue(value, out CachedType cache)) if (typeCache.TryGetValue(value, out CachedType cache))
{ AddToDict(cache);
added.Add(value);
suggestions.Add(new Suggestion(cache.DisplayName,
value,
cache.FilteredName.Substring(value.Length, cache.FilteredName.Length - value.Length),
Color.white));
}
foreach (var entry in typeCache.Values) foreach (var entry in typeCache.Values)
{ {
if (added.Contains(entry.FilteredName)) if (added.Contains(entry.FullNameValue))
continue; continue;
if (entry.FilteredName.Contains(value)) if (entry.FullNameForFilter.Contains(value))
{ AddToDict(entry);
suggestions.Add(new Suggestion(entry.DisplayName,
value, added.Add(entry.FullNameValue);
entry.FilteredName.Substring(value.Length, entry.FilteredName.Length - value.Length),
Color.white));
} }
added.Add(value); void AddToDict(CachedType entry)
{
added.Add(entry.FullNameValue);
suggestions.Add(new Suggestion(entry.DisplayName,
value,
entry.FullNameForFilter.Substring(value.Length, entry.FullNameForFilter.Length - value.Length),
entry.FullNameValue));
} }
} }
} }

View File

@ -86,8 +86,12 @@ namespace UnityExplorer.UI.Widgets
public void SetCell(ButtonCell<object> cell, int index) public void SetCell(ButtonCell<object> cell, int index)
{ {
bool objectAsType = m_context == SearchContext.StaticClass; if (m_context == SearchContext.StaticClass)
cell.buttonText.text = ToStringUtility.ToString(currentResults[index], currentResults[index].GetActualType(), objectAsType: objectAsType); {
cell.buttonText.text = SignatureHighlighter.HighlightTypeName(currentResults[index].GetActualType());
}
else
cell.buttonText.text = ToStringUtility.ToString(currentResults[index], currentResults[index].GetActualType());
} }
private void OnCellClicked(int dataIndex) private void OnCellClicked(int dataIndex)