Skip to content

Commit c06d230

Browse files
committed
feat: Started coloring missing types in red to draw attention to them.
1 parent 4034588 commit c06d230

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Editor/Drawers/TypeFieldDrawer.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,22 @@ private void DrawFieldContent(int controlID)
116116
{
117117
int indexOfComma = _serializedTypeRef.TypeNameAndAssembly.IndexOf(',');
118118
string fullTypeName = indexOfComma == -1 ? string.Empty : _serializedTypeRef.TypeNameAndAssembly.Substring(0, indexOfComma);
119-
GUIContent fieldContent = GUIContentHelper.Temp(GetTypeToShow(fullTypeName));
119+
GUIContent fieldContent = GUIContentHelper.Temp(GetTypeToShow(fullTypeName, out bool typeExists));
120+
121+
var previousColor = GUI.backgroundColor;
122+
123+
if (!typeExists)
124+
GUI.backgroundColor = new Color(1f, 0f, 0f, .5f);
125+
120126
EditorStyles.popup.Draw(_position, fieldContent, controlID);
127+
128+
GUI.backgroundColor = previousColor;
121129
}
122130

123-
private string GetTypeToShow(string typeName)
131+
private string GetTypeToShow(string typeName, out bool typeExists)
124132
{
133+
typeExists = true;
134+
125135
if (ProjectSettings.UseBuiltInNames)
126136
{
127137
string builtInName = typeName.ReplaceWithBuiltInName();
@@ -136,7 +146,10 @@ private string GetTypeToShow(string typeName)
136146
return DropdownWindow.NoneElementName;
137147

138148
if (TypeCache.GetType(_serializedTypeRef.TypeNameAndAssembly) == null)
149+
{
150+
typeExists = false;
139151
return typeName + MissingSuffix;
152+
}
140153

141154
return typeName;
142155
}

0 commit comments

Comments
 (0)