// Keybind list functions // ================================================== /// <summary> /// Populates the list of keybinds, will destroy old ones if they already exist /// </summary> public void PopulateKeybindScrollView() { Logger.Log("Populating keybind scroll view", Category.Keybindings); if (KeybindItemList.Count > 0) { Logger.Log("Removing old keybind objects", Category.Keybindings); // Destroy all items in list if it already exists foreach (GameObject item in KeybindItemList) { Destroy(item.gameObject); } KeybindItemList.Clear(); } // Reverse loop direction so items are in intended order under the headings for (int i = KeybindCount; i > 0; i--) { // Convert i to a KeyAction enum and get the corresponding keybind KeyAction action = (KeyAction)i; // Check if there is an entry for the action, not all of them will have entries if (!tempKeybinds.ContainsKey(action)) { continue; } DualKeyCombo actionKeybind = tempKeybinds[action]; KeybindMetadata actionMetadata = keybindManager.keyActionMetadata[action]; // Only add the action if it can be rebound if (!actionMetadata.Rebindable) { continue; } // Create the item and give it the same parent as the template (the scroll view content) GameObject newKeybindItem = Instantiate(KeybindItemTemplate, KeybindItemTemplate.transform.parent, false); // Add item to the list so we can destroy it again later KeybindItemList.Add(newKeybindItem); // Set the correct labels and onClick functions newKeybindItem.GetComponent <KeybindItemTemplate>().SetupKeybindItem(action, actionKeybind, actionMetadata); // Grab the index of the appropriate heading and put the keybind under it int headingIndex = KeybindHeadingDict[actionMetadata.Type].transform.GetSiblingIndex(); newKeybindItem.transform.SetSiblingIndex(headingIndex + 1); newKeybindItem.SetActive(true); } }