1.5.0: Added IntToLayerMask, marked QuaternionToEuler as obsolete as of 2021 and fixed a couple of bugs

- Drawer: Added IntToLayerMaskAttribute, if a raw int is wanted instead of LayerMask
- Drawer: Added option to either use full or short type name, when using SerializeReferenceTo
- Extension: Fixed issue, where GetValueType and GetValue for SerializedProperty would throw exceptions, if field is private
This commit is contained in:
Anders Ejlersen 2022-06-26 15:06:52 +02:00
parent ee7326c33a
commit 7d99d62e11
14 changed files with 114 additions and 17 deletions

View file

@ -15,6 +15,7 @@ namespace Module.Inspector.Editor
private static readonly Dictionary<Type, string[]> DICT_AS_STRS = new Dictionary<Type, string[]>();
private static readonly Dictionary<Type, string[]> DICT_AS_DESCS = new Dictionary<Type, string[]>();
private static readonly Dictionary<Type, GUIContent[]> DICT_AS_GUI = new Dictionary<Type, GUIContent[]>();
private static readonly Dictionary<Type, GUIContent[]> DICT_AS_GUI_SHORTNAME = new Dictionary<Type, GUIContent[]>();
private static readonly Dictionary<Type, GUIContent[]> DICT_AS_GUI_DESC = new Dictionary<Type, GUIContent[]>();
private static readonly Dictionary<Type, FieldInfo[]> DICT_AS_FIELDS = new Dictionary<Type, FieldInfo[]>();
@ -99,12 +100,12 @@ namespace Module.Inspector.Editor
return DICT_AS_STRS[type];
}
internal static GUIContent[] GetAssignableFromAsGUI(Type type)
internal static GUIContent[] GetAssignableFromAsGUI(Type type, bool useFullname = true)
{
if (!DICT_AS_GUI.ContainsKey(type))
InternalFetch(type);
return DICT_AS_GUI[type];
return useFullname ? DICT_AS_GUI[type] : DICT_AS_GUI_SHORTNAME[type];
}
internal static string[] GetAssignableFromAsDescriptions(Type type)
@ -183,6 +184,7 @@ namespace Module.Inspector.Editor
var fullnames = new string[listTypes.Count];
var descs = new string[listTypes.Count];
var guiFullNames = new GUIContent[listTypes.Count];
var guiShortnames = new GUIContent[listTypes.Count];
var guiDescs = new GUIContent[listTypes.Count];
for (var i = 0; i < fullnames.Length; i++)
@ -190,6 +192,7 @@ namespace Module.Inspector.Editor
fullnames[i] = listTypes[i].FullName;
descs[i] = $"{listTypes[i].Name} (<i>{fullnames[i]}</i>)";
guiFullNames[i] = new GUIContent(fullnames[i]);
guiShortnames[i] = new GUIContent(listTypes[i].Name);
guiDescs[i] = new GUIContent(descs[i]);
}
@ -197,6 +200,7 @@ namespace Module.Inspector.Editor
DICT_AS_STRS.Add(assignableFrom, fullnames);
DICT_AS_DESCS.Add(assignableFrom, descs);
DICT_AS_GUI.Add(assignableFrom, guiFullNames);
DICT_AS_GUI_SHORTNAME.Add(assignableFrom, guiShortnames);
DICT_AS_GUI_DESC.Add(assignableFrom, guiDescs);
}