public static System.Type TypeDropDown(Rect position, GUIContent label, System.Type baseType, System.Type selectedType, bool allowAbstractTypes = false, bool allowInterfaces = false, System.Type defaultType = null, TypeDropDownListingStyle listType = TypeDropDownListingStyle.Namespace) { if (!TypeUtil.IsType(selectedType, baseType)) selectedType = null; //var knownTypes = (from ass in System.AppDomain.CurrentDomain.GetAssemblies() // from tp in ass.GetTypes() // where TypeUtil.IsType(tp, baseType) && (allowAbstractTypes || !tp.IsAbstract) && (allowInterfaces || !tp.IsInterface) // orderby tp.FullName.Substring(tp.FullName.LastIndexOf(".") + 1) ascending // select tp).ToArray(); var knownTypes = (from tp in TypeUtil.GetTypesAssignableFrom(baseType) where (allowAbstractTypes || !tp.IsAbstract) && (allowInterfaces || !tp.IsInterface) orderby tp.FullName.Substring(tp.FullName.LastIndexOf(".") + 1) ascending select tp).ToArray(); GUIContent[] knownTypeNames = null; switch (listType) { case TypeDropDownListingStyle.Namespace: knownTypeNames = knownTypes.Select((tp) => { return new GUIContent(tp.FullName.Replace(".", "/")); }).ToArray(); break; case TypeDropDownListingStyle.Flat: knownTypeNames = (from tp in knownTypes select new GUIContent(tp.Name)).ToArray(); break; case TypeDropDownListingStyle.ComponentMenu: knownTypeNames = knownTypes.Select((tp) => { var menuAttrib = tp.GetCustomAttributes(typeof(AddComponentMenu), false).FirstOrDefault() as AddComponentMenu; if (menuAttrib != null && !string.IsNullOrEmpty(menuAttrib.componentMenu)) { return new GUIContent(menuAttrib.componentMenu); } else if (tp.FullName == tp.Name) { return new GUIContent("Scripts/" + tp.Name); } else { if (tp.FullName.StartsWith("UnityEngine.")) { return new GUIContent(tp.FullName.Replace(".", "/")); } else { return new GUIContent("Scripts/" + tp.FullName.Replace(".", "/")); } } }).ToArray(); break; default: knownTypeNames = new GUIContent[0]; break; } if (defaultType == null) { knownTypes = knownTypes.Prepend(null).ToArray(); knownTypeNames = knownTypeNames.Prepend(new GUIContent("Nothing")).ToArray(); } int index = knownTypes.IndexOf(selectedType); index = EditorGUI.Popup(position, label, index, knownTypeNames); return (index >= 0) ? knownTypes[index] : defaultType; }