public void addRecipePage(string s) { if (recipePages.transform.childCount % 2 == 0) { Transform panel = recipePages.transform; GameObject a = (GameObject)Instantiate(Resources.Load("recipe - left")); a.transform.Find("ingredient picture").GetComponent <Image>().sprite = potions[s].img; a.transform.Find("title").GetComponent <Text>().text = potions[s].ingredientName; a.transform.Find("description").GetComponent <Text>().text = potions[s].description; a.transform.Find("attributes").GetComponent <Text>().text = potions[s].attribute; a.SetActive(false); a.transform.SetParent(panel, false); } else { Transform panel = recipePages.transform; GameObject a = (GameObject)Instantiate(Resources.Load("recipe - right")); a.transform.Find("ingredient picture").GetComponent <Image>().sprite = potions[s].img; a.transform.Find("title").GetComponent <Text>().text = potions[s].ingredientName; a.transform.Find("description").GetComponent <Text>().text = potions[s].description; a.transform.Find("attributes").GetComponent <Text>().text = potions[s].attribute; a.SetActive(false); a.transform.SetParent(panel.transform, false); } if (book._currentPage == book._recipePage) { book.recipeSwitch(); } }