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.Subtractive ? EntityDebuggerStyles.ComponentSubtractive : EntityDebuggerStyles.ComponentRequired; GUILayout.Label(filterTypes[i].GetManagedType().Name, 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(); } } }
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(); } }