private void Awake() { // Load the recipies from the resources folder. this.allRecipies = Resources.LoadAll <Recipe>("recipes"); this.recipeButtons = new List <ButtonRecipe>(); // Generate all of the slots. const int btnsPerRow = 6; const float sidePad = 16; float x = sidePad; float y = -sidePad; float btnSize = this.slotPrefab.GetComponent <RectTransform>().sizeDelta.y; foreach (Recipe recipe in this.allRecipies) { if (recipe != null) { ButtonRecipe recipeBtn = GameObject.Instantiate(this.slotPrefab, this.recipeRect).GetComponent <ButtonRecipe>(); recipeBtn.transform.localPosition = new Vector3(x + (btnSize / 2), y - (btnSize / 2), 0); recipeBtn.setRecipie(recipe); this.recipeButtons.Add(recipeBtn); recipeBtn.GetComponent <Button>().onClick.AddListener(delegate { if (this.selectedRecipe != null) { this.selectedRecipe.setOutlined(false); } recipeBtn.setOutlined(true); this.setSelectedRecipe(recipeBtn); }); x += btnSize + sidePad; if (x > 500) { x = sidePad; y -= btnSize + sidePad; } } } this.updateCraftButtonInteractable(); }