/// <summary> /// Sets the category filter. /// </summary> /// <param name="index"> The selected index from the dropdown. </param> public void SetCategoryFilter(int index) { // Set category categoryFilter = index == 0 ? Origin.CategoryType.NONE : Origin.CategoryFromString(categoryDropdown.options [index].text); // Set subcategory dropdown subcategoryDropdown.gameObject.SetActive(index != 0); if (index != 0) { // Get data set Origin [] subset = NameData.Origins; // Filter by category subset = subset.Where(x => x.Category == categoryFilter).ToArray( ); // Get subcategories List <Origin.SubcategoryType> subcategories = new List <Origin.SubcategoryType> ( ); for (int i = 0; i < subset.Length; i++) { if (!subcategories.Contains(subset [i].Subcategory)) { subcategories.Add(subset [i].Subcategory); } } // Populate dropdown subcategoryDropdown.ClearOptions( ); List <string> options = new List <string> ( ); options.Add("Any Subcategory"); for (int i = 0; i < subcategories.Count; i++) { options.Add(Origin.ToString(subcategories [i])); } subcategoryDropdown.AddOptions(options); } // Hide origin dropdown originDropdown.gameObject.SetActive(false); // Set filters subcategoryFilter = Origin.SubcategoryType.NONE; subcategoryDropdown.value = 0; originFilter = "Any"; originDropdown.value = 0; // Update stats DisplayStats( ); }