1.3.0: Added SerializeReferenceTo as a helper for assigning managed type to fields with SerializeReference
This commit is contained in:
parent
ea849a715d
commit
e1d0e0e90b
8 changed files with 216 additions and 8 deletions
|
|
@ -14,7 +14,9 @@ namespace Module.Inspector.Editor
|
|||
private static readonly Dictionary<Type, Type[]> DICT_AS_TYPES = new Dictionary<Type, Type[]>();
|
||||
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_DESC = new Dictionary<Type, GUIContent[]>();
|
||||
|
||||
private static readonly Dictionary<Type, FieldInfo[]> DICT_AS_FIELDS = new Dictionary<Type, FieldInfo[]>();
|
||||
private static readonly Dictionary<Type, string[]> DICT_FIELDS_AS_STRS = new Dictionary<Type, string[]>();
|
||||
private static readonly Dictionary<Type, string[]> DICT_FIELDS_AS_DESCS = new Dictionary<Type, string[]>();
|
||||
|
|
@ -96,6 +98,14 @@ namespace Module.Inspector.Editor
|
|||
|
||||
return DICT_AS_STRS[type];
|
||||
}
|
||||
|
||||
internal static GUIContent[] GetAssignableFromAsGUI(Type type)
|
||||
{
|
||||
if (!DICT_AS_GUI.ContainsKey(type))
|
||||
InternalFetch(type);
|
||||
|
||||
return DICT_AS_GUI[type];
|
||||
}
|
||||
|
||||
internal static string[] GetAssignableFromAsDescriptions(Type type)
|
||||
{
|
||||
|
|
@ -105,6 +115,14 @@ namespace Module.Inspector.Editor
|
|||
return DICT_AS_DESCS[type];
|
||||
}
|
||||
|
||||
internal static GUIContent[] GetAssignableFromAsGUIDescriptions(Type type)
|
||||
{
|
||||
if (!DICT_AS_GUI_DESC.ContainsKey(type))
|
||||
InternalFetch(type);
|
||||
|
||||
return DICT_AS_GUI_DESC[type];
|
||||
}
|
||||
|
||||
internal static FieldInfo[] GetFields(Type type)
|
||||
{
|
||||
if (!DICT_AS_FIELDS.ContainsKey(type))
|
||||
|
|
@ -164,16 +182,22 @@ namespace Module.Inspector.Editor
|
|||
listTypes.Sort((t0, t1) => string.Compare(t0.Name, t1.Name, StringComparison.Ordinal));
|
||||
var fullnames = new string[listTypes.Count];
|
||||
var descs = new string[listTypes.Count];
|
||||
var guiFullNames = new GUIContent[listTypes.Count];
|
||||
var guiDescs = new GUIContent[listTypes.Count];
|
||||
|
||||
for (var i = 0; i < fullnames.Length; i++)
|
||||
{
|
||||
fullnames[i] = listTypes[i].FullName;
|
||||
descs[i] = $"{listTypes[i].Name} (<i>{fullnames[i]}</i>)";
|
||||
guiFullNames[i] = new GUIContent(fullnames[i]);
|
||||
guiDescs[i] = new GUIContent(descs[i]);
|
||||
}
|
||||
|
||||
DICT_AS_TYPES.Add(assignableFrom, listTypes.ToArray());
|
||||
DICT_AS_STRS.Add(assignableFrom, fullnames);
|
||||
DICT_AS_DESCS.Add(assignableFrom, descs);
|
||||
DICT_AS_GUI.Add(assignableFrom, guiFullNames);
|
||||
DICT_AS_GUI_DESC.Add(assignableFrom, guiDescs);
|
||||
}
|
||||
|
||||
private static void InternalFetchFields(Type type)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue