private static void SetupStoreModalButtons() { if (store_ui) { //Transform store = store_ui.FindChild("Store_Modal"); Transform general_store = store_ui.FindChild("General_Store_Modal"); storeCloseButton = general_store.FindChild("Button").gameObject.GetComponent <Button>(); Button.ButtonClickedEvent evnt = new Button.ButtonClickedEvent(); evnt.AddListener(() => { Toggle("general_store"); }); storeCloseButton.onClick = evnt; // Setup the Products // Grab the Product Template Transform products = general_store.FindChild("Products"); Transform productTemplate = products.FindChild("Product_Template"); List <Transform> productBtns = new List <Transform>(); foreach (string productId in StoreManager.ProductIDs) { Transform clone = (Transform)GameObject.Instantiate(productTemplate, productTemplate.position, Quaternion.identity); productBtns.Add(clone); clone.transform.SetParent(products, false); StoreManager.ProductDescription prodDesc = StoreManager.ProductInfoMap[productId]; clone.name = productId; clone.FindChild("Product_Name").gameObject.GetComponent <Text>().text = prodDesc.display_name; clone.FindChild("Product_Cost").gameObject.GetComponent <Text>().text = prodDesc.price; clone.gameObject.SetActive(true); //TODO set the icon Button.ButtonClickedEvent prodBuy = new Button.ButtonClickedEvent(); string s = productId; prodBuy.AddListener(() => { Debug.Log("Buy Product: " + s); StoreManager.BuyProductID(s); }); clone.GetComponent <Button>().onClick = prodBuy; } productTemplate.gameObject.SetActive(false); } }