void ShowHeaders() { for (int i = 0; i < mappings.Count; i++) { InputMapping mapping = mappings[i]; if (headers.Count > i) { //Fill old header headers[i].Fill(mapping.displayName, i); } else { //New Header //Spawn KeyBindingHeader header = Instantiate(headerPrefab.gameObject).GetComponent <KeyBindingHeader>(); header.transform.SetParent(headerPrefab.transform.parent); header.transform.localScale = Vector3.one; //Listener header.onClick.AddListener(OnHeaderClick); //List headers.Add(header); //Fill with data header.Fill(mapping.displayName, i); } } }
void OnHeaderClick(KeyBindingHeader header) { ShowMapping(header.Index); }