private bool IsCatEmpty(int CatID) { TriviaDatabase triviaData = CommonFunctions.LoadTriviaDatabase(); for (int i = 0; i < triviaData.COUNT; i++) { if (triviaData.Trivia(i).category == CatID) { return(false); } } return(true); }
private void DisplayTrivia() { EditorGUILayout.BeginVertical(GUILayout.Width(250)); EditorGUILayout.Space(); catListToBeFiltered.Insert(0, "All"); catFiltered = EditorGUILayout.Popup("Filter By Category: ", catFiltered, catListToBeFiltered.ToArray()); int catFilterID = 0; if (catFiltered != 0) { filterTrivia = true; catFilterID = categoryDatabase.Category(catFiltered - 1).categoryID; } else { filterTrivia = false; } scrollPos = EditorGUILayout.BeginScrollView(scrollPos, "box", GUILayout.ExpandHeight(true)); for (int cnt = 0; cnt < triviaDatabase.COUNT; cnt++) { if (Filter(cnt, catFilterID)) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("-", GUILayout.Width(25))) { triviaDatabase.RemoveAt(cnt); EditorUtility.SetDirty(triviaDatabase); state = State.BLANK; return; } GUI.SetNextControlName("Clear"); if (GUILayout.Button(triviaDatabase.Trivia(cnt).question, "box", GUILayout.ExpandWidth(true))) { GUI.FocusControl("Clear"); seletedTrivia = cnt; state = State.EDIT; } EditorGUILayout.EndHorizontal(); } } EditorGUILayout.EndScrollView(); EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); EditorGUILayout.LabelField("Questions: " + triviaDatabase.COUNT, GUILayout.Width(100)); if (GUILayout.Button("New Trivia")) { state = State.ADD; } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.EndVertical(); }