Skip to content

Commit 99baede

Browse files
committed
Fix building name for some generic types; fix drawing SerializedDictionary for non-serializable value/key types
1 parent 67aa037 commit 99baede

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

Assets/Editor Toolbox/Editor/Drawers/Toolbox/TargetType/SerializedDictionaryDrawer.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,19 @@ static SerializedDictionaryDrawer()
5252
var content = list.GetElementContent(element, index);
5353
using (new EditorGUILayout.HorizontalScope())
5454
{
55-
var kOption = GUILayout.Width(Style.kGroupWidth);
56-
DrawDictionaryProperty(kProperty, Style.kLabel, Style.kLabelWidth, kOption);
57-
58-
var vLabel = vProperty.hasVisibleChildren
59-
? Style.vLabel
60-
: GUIContent.none;
61-
DrawDictionaryProperty(vProperty, vLabel, Style.vLabelWidth);
55+
if (kProperty != null)
56+
{
57+
var kOption = GUILayout.Width(Style.kGroupWidth);
58+
DrawDictionaryProperty(kProperty, Style.kLabel, Style.kLabelWidth, kOption);
59+
}
60+
61+
if (vProperty != null)
62+
{
63+
var vLabel = vProperty.hasVisibleChildren
64+
? Style.vLabel
65+
: GUIContent.none;
66+
DrawDictionaryProperty(vProperty, vLabel, Style.vLabelWidth);
67+
}
6268
}
6369
};
6470
return list;

Assets/Editor Toolbox/Editor/Internal/Types/TypesEditorCollection.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,21 @@ private static string GetTypeName(Type type, bool createFull)
7676
stringBuilder.Append(':');
7777
}
7878

79-
if (type.IsGenericType)
79+
var typeName = type.Name;
80+
//NOTE: there are rare cases where "generic" types have no arguments, let's ignore them
81+
if (type.IsGenericType && typeName.Contains("`"))
8082
{
81-
var name = type.Name;
82-
name = name.Substring(0, name.IndexOf("`"));
83+
var genericCharIndex = typeName.IndexOf("`");
84+
typeName = typeName.Substring(0, genericCharIndex);
8385

84-
stringBuilder.Append(name);
86+
stringBuilder.Append(typeName);
8587
stringBuilder.Append('<');
8688
var arguments = type.GetGenericArguments();
8789
for (var i = 0; i < arguments.Length; i++)
8890
{
89-
var argumentType = arguments[i];
91+
var argumentType = arguments[i];
9092
var argumentName = string.IsNullOrEmpty(argumentType.FullName)
91-
? argumentType.Name
93+
? argumentType.Name
9294
: GetTypeName(argumentType, false);
9395

9496
stringBuilder.Append(argumentName);
@@ -102,7 +104,7 @@ private static string GetTypeName(Type type, bool createFull)
102104
}
103105
else
104106
{
105-
stringBuilder.Append(type.Name);
107+
stringBuilder.Append(typeName);
106108
}
107109

108110
return stringBuilder.ToString();

0 commit comments

Comments
 (0)