Vector2 DrawItemIDAbility(float startX, float startY, Perk perk, int limit = 1) { string[] abilityNameList = EditorDBManager.GetAbilityNameList(); List <Ability> abilityList = EditorDBManager.GetAbilityList(); if (perk.itemIDList.Count == 0) { perk.itemIDList.Add(-1); } while (perk.itemIDList.Count > limit) { perk.itemIDList.RemoveAt(perk.itemIDList.Count - 1); } for (int i = 0; i < perk.itemIDList.Count; i++) { int ID = perk.itemIDList[i]; if (ID >= 0) { for (int n = 0; n < abilityList.Count; n++) { if (abilityList[n].ID == ID) { ID = n + 1; break; } } } cont = new GUIContent(" - Ability:", "The ability to add to game when the perk is unlocked"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); ID = EditorGUI.Popup(new Rect(startX + spaceX - 20, startY, width, 15), ID, abilityNameList); if (ID > 0 && !perk.itemIDList.Contains(abilityList[ID - 1].ID)) { perk.itemIDList[i] = abilityList[ID - 1].ID; } else if (ID == 0) { perk.itemIDList[i] = -1; } //if the list is full, extend it if (i == perk.itemIDList.Count - 1 && ID >= 0 && perk.itemIDList.Count < limit) { perk.itemIDList.Add(-1); } //if one of the element in the list is empty, shrink it if (i < perk.itemIDList.Count - 1 && perk.itemIDList[i] == -1) { perk.itemIDList.RemoveAt(i); i -= 1; } } return(new Vector2(startX, startY)); }