/// <summary> /// Get types from the current AppDomain with a specified <see cref="AssemblyTypeFlags"/> filter. /// </summary> /// <param name="assemblyTypeFlags">The <see cref="AssemblyTypeFlags"/> filters.</param> /// <returns>Types from the current AppDomain with the specified <see cref="AssemblyTypeFlags"/> filters.</returns> public static IEnumerable <Type> GetTypes(AssemblyTypeFlags assemblyTypeFlags) { bool includeUserTypes = (assemblyTypeFlags & AssemblyTypeFlags.UserTypes) == AssemblyTypeFlags.UserTypes; bool includeUserEditorTypes = (assemblyTypeFlags & AssemblyTypeFlags.UserEditorTypes) == AssemblyTypeFlags.UserEditorTypes; bool includePluginTypes = (assemblyTypeFlags & AssemblyTypeFlags.PluginTypes) == AssemblyTypeFlags.PluginTypes; bool includePluginEditorTypes = (assemblyTypeFlags & AssemblyTypeFlags.PluginEditorTypes) == AssemblyTypeFlags.PluginEditorTypes; bool includeUnityTypes = (assemblyTypeFlags & AssemblyTypeFlags.UnityTypes) == AssemblyTypeFlags.UnityTypes; bool includeUnityEditorTypes = (assemblyTypeFlags & AssemblyTypeFlags.UnityEditorTypes) == AssemblyTypeFlags.UnityEditorTypes; bool includeOtherTypes = (assemblyTypeFlags & AssemblyTypeFlags.OtherTypes) == AssemblyTypeFlags.OtherTypes; if (includeUserTypes) { for (int i = 0; i < userTypes.Count; i++) { yield return(userTypes[i]); } } if (includeUserEditorTypes) { for (int i = 0; i < userEditorTypes.Count; i++) { yield return(userEditorTypes[i]); } } if (includePluginTypes) { for (int i = 0; i < pluginTypes.Count; i++) { yield return(pluginTypes[i]); } } if (includePluginEditorTypes) { for (int i = 0; i < pluginEditorTypes.Count; i++) { yield return(pluginEditorTypes[i]); } } if (includeUnityTypes) { for (int i = 0; i < unityTypes.Count; i++) { yield return(unityTypes[i]); } } if (includeUnityEditorTypes) { for (int i = 0; i < unityEditorTypes.Count; i++) { yield return(unityEditorTypes[i]); } } if (includeOtherTypes) { for (int i = 0; i < otherTypes.Count; i++) { yield return(otherTypes[i]); } } }
private void DrawFirstToolbar() { GUILayout.Space(1); var typeName = " " + (this.targetType == null ? "Select Type" : this.targetType.GetNiceFullName()) + " "; var rect = GUILayoutUtility.GetRect(0, 21, SirenixGUIStyles.ToolbarBackground); var rect2 = rect.AlignRight(80); var rect1 = rect.SetXMax(rect2.xMin); TypeSelector.DrawSelectorDropdown(rect1, new GUIContent(typeName), SelectType, btnStyle); EditorGUI.BeginChangeCheck(); this.targetTypeFlags = EnumSelector <AssemblyTypeFlags> .DrawEnumField(rect2, null, new GUIContent("Type Filter"), this.targetTypeFlags, btnStyle); if (EditorGUI.EndChangeCheck()) { EditorPrefs.SetInt(TargetTypeFlagsPrefKey, (int)this.targetTypeFlags); } if (Event.current.type == EventType.Repaint) { var icon = GUIHelper.GetAssetThumbnail(null, this.targetType ?? typeof(int), false); if (icon != null) { rect1.x += 8; GUI.DrawTexture(rect1.AlignLeft(16).AlignMiddle(16), icon, ScaleMode.ScaleToFit); } } }
public TypeSelector(AssemblyTypeFlags assemblyFlags, bool supportsMultiSelect) { this.types = null; this.supportsMultiSelect = supportsMultiSelect; this.assemblyTypeFlags = assemblyFlags; }