public void OnGUI() { GUILayout.Label("Filter: "); var filterCount = 0; for (var i = 0; i < selectedFilterTypes.Count; ++i) { if (selectedFilterTypes[i]) { ++filterCount; var style = filterTypes[i].AccessModeType == ComponentType.AccessMode.Exclude ? EntityDebuggerStyles.ComponentExclude : EntityDebuggerStyles.ComponentRequired; GUILayout.Label(EntityQueryGUI.SpecifiedTypeName(filterTypes[i].GetManagedType()), style); } } if (filterCount == 0) { GUILayout.Label("none"); } if (GUILayout.Button("Edit")) { ComponentTypeChooser.Open(GUIUtility.GUIToScreenPoint(GUILayoutUtility.GetLastRect().position), filterTypes, selectedFilterTypes, ComponentFilterChanged); } if (filterCount > 0) { if (GUILayout.Button("Clear")) { for (var i = 0; i < selectedFilterTypes.Count; ++i) { selectedFilterTypes[i] = false; } ComponentFilterChanged(); } } }
int CompareTypes(ComponentType lhs, ComponentType rhs) { bool isLeftSelected = selectedFilterTypes.Contains(lhs); bool isRightSelected = selectedFilterTypes.Contains(rhs); if (isLeftSelected == isRightSelected) { return(EntityQueryGUI.CompareTypes(lhs, rhs)); } return(isLeftSelected ? -1 : 1); }
public ComponentTypeListView(TreeViewState state, List <ComponentType> types, List <bool> typeSelections, CallbackAction callback) : base(state) { this.callback = callback; this.types = types; this.typeSelections = typeSelections; typeNames = new List <GUIContent>(types.Count); for (var i = 0; i < types.Count; ++i) { typeNames.Add(new GUIContent(EntityQueryGUI.SpecifiedTypeName(types[i].GetManagedType()))); } Reload(); }
public void OnGUI(int matches) { int firstActiveFilter = -1; for (var i = 0; i < selectedFilterTypes.Count; i++) { if (selectedFilterTypes[i]) { firstActiveFilter = i; break; } } GUILayout.BeginHorizontal(); if (GUILayout.Button("Filter")) { ComponentTypeChooser.Open(GUIUtility.GUIToScreenPoint(GUILayoutUtility.GetLastRect().position), filterTypes, selectedFilterTypes, ComponentFilterChanged); } if (firstActiveFilter >= 0) { if (GUILayout.Button("Clear")) { for (var i = 0; i < selectedFilterTypes.Count; ++i) { selectedFilterTypes[i] = false; } ComponentFilterChanged(); } } GUILayout.FlexibleSpace(); GUILayout.Label("Matching entities: " + matches); GUILayout.EndHorizontal(); if (firstActiveFilter >= 0) { GUILayout.BeginHorizontal(); for (var i = firstActiveFilter; i < selectedFilterTypes.Count; ++i) { if (selectedFilterTypes[i]) { var style = filterTypes[i].AccessModeType == ComponentType.AccessMode.Exclude ? EntityDebuggerStyles.ComponentExclude : EntityDebuggerStyles.ComponentRequired; GUILayout.Label(EntityQueryGUI.SpecifiedTypeName(filterTypes[i].GetManagedType()), style); } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } }
public void OnGUI(int matches) { GUILayout.BeginHorizontal(); if (GUILayout.Button("Filter")) { var filterTypesWithSelected = new List <ComponentType>(selectedFilterTypes); filterTypesWithSelected.Sort(EntityQueryGUI.CompareTypes); previouslySelected.RemoveAll(selectedFilterTypes.Contains); if (previouslySelected.Count > k_HistorySize) { previouslySelected.RemoveRange(k_HistorySize, previouslySelected.Count - k_HistorySize); } filterTypesWithSelected.AddRange(previouslySelected); filterTypesWithSelected.AddRange(filterTypes.Where(t => !previouslySelected.Contains(t) && !selectedFilterTypes.Contains(t))); ComponentTypeChooser.Open( GUIUtility.GUIToScreenPoint(GUILayoutUtility.GetLastRect().position), filterTypesWithSelected, selectedFilterTypes, previouslySelected, ComponentFilterChanged ); } if (selectedFilterTypes.Count > 0) { if (GUILayout.Button("Clear")) { selectedFilterTypes.Clear(); ComponentFilterChanged(); } } GUILayout.FlexibleSpace(); GUILayout.Label("Matching entities: " + matches); GUILayout.EndHorizontal(); if (selectedFilterTypes.Count > 0) { GUILayout.BeginHorizontal(); foreach (var filter in selectedFilterTypes) { var style = filter.AccessModeType == ComponentType.AccessMode.Exclude ? EntityDebuggerStyles.ComponentExclude : EntityDebuggerStyles.ComponentRequired; GUILayout.Label(EntityQueryGUI.SpecifiedTypeName(filter.GetManagedType()), style); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } }
void CalculateDrawingParts(IEnumerable <ComponentType> types, IEnumerable <ComponentType> readWriteTypes, bool archetypeQueryMode) { var typeList = types.ToList(); typeList.Sort((Comparison <ComponentType>)EntityQueryGUI.CompareTypes); styles = new List <GUIStyle>(typeList.Count); names = new List <GUIContent>(typeList.Count); rects = new List <Rect>(typeList.Count); foreach (var type in typeList) { GUIStyle style = null; if (readWriteTypes != null) { if (type.AccessModeType == ComponentType.AccessMode.Exclude) { style = EntityDebuggerStyles.ComponentExclude; } else { foreach (var readWriteType in readWriteTypes) { if (readWriteType.TypeIndex == type.TypeIndex) { style = EntityQueryGUI.StyleForAccessMode(readWriteType.AccessModeType, archetypeQueryMode); break; } } if (style == null) { style = EntityDebuggerStyles.ComponentRequired; } } } else { style = EntityQueryGUI.StyleForAccessMode(type.AccessModeType, archetypeQueryMode); } var content = new GUIContent((string)EntityQueryGUI.SpecifiedTypeName(type.GetManagedType())); styles.Add(style); names.Add(content); } }