//function to refresh the crafting table public void RefreshTable() { //clears out all instantiated buttons foreach (Transform child in GameObject.Find("Content").transform) { Destroy(child.gameObject); } craftList = new List <Attachments>(); //for loop to iterate over all attachments and add craftables to the crafting list foreach (Attachments.Name name in System.Enum.GetValues(typeof(Attachments.Name))) { Attachments checkAttach = new Attachments { attachmentName = name }; if (checkAttach.CheckCraftable() == true) { craftList.Add(new Attachments { attachmentName = name }); } } //for loop to create the list of craftables buttons for (int i = 0; i < craftList.Count; i++) { bool alreadyHave = false; //checks to see if you already have the attachment crafted foreach (Attachments attach in inventory.attachmentList) { //if you already have crafted if (attach.attachmentName == craftList[i].attachmentName) { InstanceCrafted(new Attachments { attachmentName = craftList[i].attachmentName }); alreadyHave = true; } } if (!alreadyHave) { //creates a craftable button for the attachment InstanceCraftable(new Attachments { attachmentName = craftList[i].attachmentName }); } } }