mirror of
https://github.com/codewriter-packages/Tri-Inspector.git
synced 2025-01-22 08:18:49 -05:00
Fix incorrect nested class names in reference dropdown
This commit is contained in:
parent
a0c5ca5037
commit
1a5b5a7468
@ -13,7 +13,10 @@ namespace TriInspector.Utilities
|
||||
{
|
||||
public static void DrawTypeSelector(Rect rect, TriProperty property)
|
||||
{
|
||||
var typeNameContent = new GUIContent(property.ValueType?.Name ?? "[None]");
|
||||
var typeName = property.ValueType != null
|
||||
? TriTypeUtilities.GetTypeNiceName(property.ValueType)
|
||||
: "[None]";
|
||||
var typeNameContent = new GUIContent(typeName);
|
||||
|
||||
if (EditorGUI.DropdownButton(rect, typeNameContent, FocusType.Passive))
|
||||
{
|
||||
@ -141,7 +144,8 @@ namespace TriInspector.Utilities
|
||||
|
||||
private class ReferenceTypeItem : AdvancedDropdownItem
|
||||
{
|
||||
public ReferenceTypeItem(Type type, Texture2D preview = null) : base(type?.Name ?? "[None]")
|
||||
public ReferenceTypeItem(Type type, Texture2D preview = null)
|
||||
: base(type != null ? TriTypeUtilities.GetTypeNiceName(type) : "[None]")
|
||||
{
|
||||
Type = type;
|
||||
icon = preview;
|
||||
|
31
Editor/Utilities/TriTypeUtilities.cs
Normal file
31
Editor/Utilities/TriTypeUtilities.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TriInspector.Utilities
|
||||
{
|
||||
public static class TriTypeUtilities
|
||||
{
|
||||
private static readonly Dictionary<Type, string> TypeNiceNames = new Dictionary<Type, string>();
|
||||
|
||||
public static string GetTypeNiceName(Type type)
|
||||
{
|
||||
if (TypeNiceNames.TryGetValue(type, out var niceName))
|
||||
{
|
||||
return niceName;
|
||||
}
|
||||
|
||||
niceName = type.Name;
|
||||
|
||||
while (type.DeclaringType != null)
|
||||
{
|
||||
niceName = type.DeclaringType.Name + "." + niceName;
|
||||
|
||||
type = type.DeclaringType;
|
||||
}
|
||||
|
||||
TypeNiceNames[type] = niceName;
|
||||
|
||||
return niceName;
|
||||
}
|
||||
}
|
||||
}
|
3
Editor/Utilities/TriTypeUtilities.cs.meta
Normal file
3
Editor/Utilities/TriTypeUtilities.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cd64ca1178f24265a0eea33c5dfbb3c9
|
||||
timeCreated: 1690816481
|
Loading…
Reference in New Issue
Block a user