//-------------------------------------------------------------------- //-Player inventory Code --------------------------------------------- //-------------------------------------------------------------------- private void PlayerAddButtons() { for (int i = 0; i < playerList.Count; i++) { Item item = playerList[i].itemShop; GameObject newButton = playerObjectPool.GetObject(); newButton.transform.SetParent(playerContentPainel.transform); SampleButton sampleButton = newButton.GetComponent <SampleButton>(); for (int j = 0; j < shopItemList.Count; j++) { if (item.itemName == shopItemList[j].itemShop.itemName) { haveItemOnShop = true; shopPositonItemPriceTemp = j; } } if (haveItemOnShop) { sampleButton.Setup(item, this, playerContentPainel, i, shopItemList[shopPositonItemPriceTemp]); } else { sampleButton.Setup(item, this, playerContentPainel, i); } playerButtonList.Add(sampleButton); playerButtonList[i].tempShopPrices.amount = playerList[i].amount; playerButtonList[i].UpdateAmountPlayer(); } }
public void SwitchToLevels(int index) { string curLangSet = PlayerPrefs.GetString("setLang", "EN"); string textLevel = "NoName"; if (curLangSet == "PL") { textLevel = "Poziom "; tLevelsPackName.text = levelPackList[index].nameOfPack_Pol; } else { textLevel = "Level "; tLevelsPackName.text = levelPackList[index].nameOfPack_Eng; } foreach (Transform child in contentPanelLevels) { GameObject.Destroy(child.gameObject); } //contentPanelLevels.DetachChildren(); for (int i = 0; i < levelPackList[index].textAssetList.Count; i++) { GameObject newButton = buttonObjectPoolLevels.GetObject(); newButton.transform.SetParent(contentPanelLevels); SampleButton sampleButton = newButton.GetComponent <SampleButton>(); sampleButton.Setup(textLevel + (i + 1).ToString(), this, index, i); } goLevelsPacks.SetActive(false); goLevels.SetActive(true); }
protected void AddButton(string text, Storage stor) { GameObject newButton = buttonObjectPool.GetObject(); newButton.transform.SetParent(contentPanel, true); SampleButton sampleButton = newButton.GetComponent <SampleButton>(); if (stor == null) { sampleButton.Setup(text, this, null); } else { sampleButton.Setup(text, this, stor.getProduct()); } }
public void AddButtons() { foreach (Transform child in contentPanelLevelsPack) { GameObject.Destroy(child.gameObject); } string curLangSet = PlayerPrefs.GetString("setLang", "EN"); for (int i = 0; i < levelPackList.Count; i++) { GameObject newButton = buttonObjectPoolLevelsPack.GetObject(); newButton.transform.SetParent(contentPanelLevelsPack); string tempText = "NoName"; if (curLangSet == "PL") { tempText = levelPackList[i].nameOfPack_Pol; } else { tempText = levelPackList[i].nameOfPack_Eng; } SampleButton sampleButton = newButton.GetComponent <SampleButton>(); sampleButton.Setup(tempText, this, i, 0); } }
protected void AddButton(string text, Factory stor) { GameObject newButton = buttonObjectPool.GetObject(); newButton.transform.SetParent(contentPanel, true); SampleButton sampleButton = newButton.GetComponent <SampleButton>(); sampleButton.Setup(text, this, stor); }
void AddButtons() { for (int i = 0; i < itemList.Count; i++) { Item item = itemList[i]; GameObject newButton = Instantiate(buttonPrefab, contentPanel); SampleButton sampleButton = newButton.GetComponent <SampleButton>(); sampleButton.Setup(item, this); } }
private void AddBuildButtons() { databaseReference = FirebaseDatabase.DefaultInstance.RootReference; Debug.Log("======= ADDING BUILD BUTTONS ========"); FirebaseDatabase.DefaultInstance.GetReference("users").Child(username_static.userId).GetValueAsync().ContinueWith(task => { if (task.IsFaulted) { //Handle Error Debug.Log("ERROR ==" + task.IsFaulted); } else if (task.IsCompleted) { DataSnapshot snapshot = task.Result; List <string> mazeTitles = new List <string>(); foreach (DataSnapshot data in snapshot.Children) { mazeTitles.Add(data.Key); //GameObject newButton = buttonObjectPool.GetObject(); //newButton.transform.SetParent(contentPanel); } foreach (string title in mazeTitles) { Debug.Log(title); GameObject newButton = buttonObjectPool.GetObject(); newButton.transform.SetParent(contentPanel); SampleButton sampleButton = newButton.GetComponent <SampleButton>(); sampleButton.Setup(title, this, buildMode, playMode, username_static.userId); } } }); //if (File.Exists(Application.persistentDataPath + "/userMazeData.data")) //{ // Debug.Log("== SAVE FILE EXISTS FOR SCROLL =="); // // Load the information of userMazeData from file // BinaryFormatter bf = new BinaryFormatter(); // FileStream file = File.Open(Application.persistentDataPath + "/userMazeData.data", FileMode.Open); // Debug.Log(Application.persistentDataPath); // UserMazeData userMazeData = (UserMazeData)bf.Deserialize(file); // file.Close(); // MazeCollection mazeCollection = userMazeData.getMazeByUsername(username_static.username); // Dictionary<String, MazeData> collection = mazeCollection.getCollection(); // foreach (KeyValuePair<String, MazeData> mazeData in collection) // { // Debug.Log("== =="); // GameObject newButton = buttonObjectPool.GetObject(); // newButton.transform.SetParent(contentPanel); // SampleButton sampleButton = newButton.GetComponent<SampleButton>(); // sampleButton.Setup(mazeData.Value, mazeData.Key, this); // } //} }
//-------------------------------------------------------------------- //-Add to Inventory Code---------------------------------------------- //-------------------------------------------------------------------- private void AddToButtonsShopInventory() { for (int i = 0; i < shopItemList.Count; i++) { Item item = shopItemList[i].itemShop; GameObject newButton = buttonObjectPool.GetObject(); newButton.transform.SetParent(contentPanel.transform); SampleButton sampleButton = newButton.GetComponent <SampleButton>(); sampleButton.Setup(item, this, contentPanel, i, shopItemList[i]); } }
protected void AddButton(string text, FactoryType type) { GameObject newButton = buttonObjectPool.GetObject(); newButton.transform.SetParent(contentPanel, true); SampleButton sampleButton = newButton.GetComponent <SampleButton>(); //if (inventionType == null) // sampleButton.Setup(text, this, null); //else sampleButton.Setup(text, this, type); }
protected void AddButton(string text, PopUnit record) { GameObject newButton = buttonObjectPool.GetObject(); newButton.transform.SetParent(contentPanel, true); //newButton.transform.SetParent(contentPanel); //newButton.transform.localScale = Vector3.one; SampleButton sampleButton = newButton.GetComponent <SampleButton>(); sampleButton.Setup(text, this, record); }
public void AddButtons() { for (int i = 0; i < Player.propertyList.Count; i++) { string nieruchomosci = Player.propertyList[i]; newButton = buttonObjectPool.GetObject(); newButton.GetComponentInChildren <Text>().text = Player.propertyList[i]; newButton.transform.SetParent(contentPanel, false); SampleButton sampleButton = newButton.GetComponent <SampleButton>(); sampleButton.Setup(nieruchomosci, scrollList); } }
private void AddButtons() { for (int i = 0; i < itemList.Count; i++) { Item item = itemList[i]; GameObject newButton = buttonObjectPool.GetObject(); newButton.transform.SetParent(contentPanel); SampleButton sampleButton = newButton.GetComponent <SampleButton>(); sampleButton.Setup(item, this); } }
private void AddButtons() { SceneTitle.text = "Players"; for (int i = 0; i < playerlist.Count; i++) { Player player = playerlist[i]; GameObject newButton = buttonObjectPool.GetObject(); newButton.transform.SetParent(contentPanel); SampleButton sampleButton = newButton.GetComponent <SampleButton>(); sampleButton.Setup(player, this); } }
void AddButtons() { for (int i = 0; i < itemList.Count; i++) { Item item = itemList [i]; GameObject newButton = (GameObject)Instantiate(buttonPrefab); newButton.transform.SetParent(contentPanel); newButton.transform.localScale = new Vector3(1, 1, 1); SampleButton sampleButton = newButton.GetComponent <SampleButton> (); sampleButton.Setup(item, this); } }
//-------------------------------------------------------------------- //-Player to sell cart code ------------------------------------------ //-------------------------------------------------------------------- private void PlayerSellCartAddButton() { for (int i = 0; i < playerSellList.Count; i++) { Item item = playerSellList[i].itemShop; GameObject newButton = playerSellObjectPool.GetObject(); newButton.transform.SetParent(playerSellContentPainel.transform); SampleButton sampleButton = newButton.GetComponent <SampleButton>(); for (int j = 0; j < shopItemList.Count; j++) { if (item.itemName == shopItemList[j].itemShop.itemName) { findItemOnShopToCopyValue = true; shopPositonItemPriceTemp = j; } } if (!findItemOnShopToCopyValue) { ItemOnShop itm = new ItemOnShop(); itm.SpringBuy = item.buyValue; itm.AutumBuy = item.buyValue; itm.WinterBuy = item.buyValue; itm.SummerBuy = item.buyValue; itm.SpringSell = item.sellValue; itm.AutumSell = item.sellValue; itm.WinterSell = item.sellValue; itm.SummerSell = item.sellValue; sampleButton.Setup(item, this, playerSellContentPainel, i, itm); playerSellButtonList.Add(sampleButton); } else { sampleButton.Setup(item, this, playerSellContentPainel, i, shopItemList[shopPositonItemPriceTemp]); playerSellButtonList.Add(sampleButton); } findItemOnShopToCopyValue = false; } }
protected void AddButton(string text, PopUnit record, Func <string> dynamicTooltip) { GameObject newButton = buttonObjectPool.GetObject(); newButton.transform.SetParent(contentPanel, true); //newButton.transform.SetParent(contentPanel); //newButton.transform.localScale = Vector3.one; SampleButton sampleButton = newButton.GetComponent <SampleButton>(); sampleButton.Setup(text, this, record); newButton.GetComponentInChildren <ToolTipHandler>().dynamicString = dynamicTooltip; newButton.GetComponentInChildren <ToolTipHandler>().tip = MainTooltip.thatObj; }
private void AddButtons(Item item) { currentShopList.Add(item); GameObject newButton = (GameObject)GameObject.Instantiate(prefab); newButton.transform.SetParent(contentPanel, false); SampleButton sampleButton = newButton.GetComponent <SampleButton>(); sampleButton.Setup(item, this); gameobjectShopList.Add(newButton); RefreshDisplay(); gm.currentShopList = currentShopList; }
public void AddButtons(List <Games> gamesToAdd) { gameList = gamesToAdd; for (int i = 0; i < gameList.Count; i++) { Games game = gameList[i]; GameObject newButton = buttonObjectPool.GetObject(); newButton.transform.SetParent(gamelistPanel); newButton.transform.localScale = new Vector3(1, 1, 1); SampleButton sampleButton = newButton.GetComponent <SampleButton>(); sampleButton.Setup(game, this); } }
private void AddButtons() { //Debug.Log (itemList); for (int i = 0; i < itemList.Count; i++) { Debug.Log("once"); Item item = itemList[i]; GameObject newButton = buttonObjectPool.GetObject(); Debug.Log(newButton.tag); newButton.transform.SetParent(contentPanel, false); SampleButton sampleButton = newButton.GetComponent <SampleButton>(); sampleButton.Setup(item, this); } }
void CreateButton(List <Item> items) { foreach (Item item in items) { GameObject newButton = buttonObjectPool.GetObject(); newButton.transform.SetParent(contentPanel, false); SampleButton sampleButton = newButton.GetComponent <SampleButton>(); sampleButton.Setup(item, this); sampleButton.GetComponent <Button>().onClick.AddListener(() => { EMusic.GetComponent <AudioSource>().clip = Resources.Load <AudioClip>("EMusic/Click"); EMusic.GetComponent <AudioSource>().Play(); }); } }
private void AddButtons() { for (int i = 0; i < itemList.Count; i++) { itemList[i].index = i; itemList[i].price = SaveManager.Instance.costs[i]; itemList[i].numOwned = SaveManager.Instance.upgrades[i]; itemList[i].description = SaveManager.Instance.upgradesDes[i]; Item item = itemList[i]; GameObject newButton = buttonObjectPool.GetObject(); newButton.transform.SetParent(contentPanel); SampleButton sampleButton = newButton.GetComponent <SampleButton>(); sampleButton.Setup(item, this); } }
protected void AddButtons() { for (int i = 0; i < ItemList.Count; i++) { Item newItem = ItemList[i]; GameObject newButton = ButtonObjectPool.GetObject(); newButton.transform.FindChild("ItemNameText").GetComponent <Text>().color = newItem.TextColor; newButton.transform.FindChild("ItemPriceText").GetComponent <Text>().color = newItem.TextColor; newButton.transform.SetParent(ContentPanel); newButton.transform.localScale = localScaleVector3; SampleButton sampleButton = newButton.GetComponent <SampleButton>(); SetButtonSize(sampleButton.button); sampleButton.Setup(newItem, this); } }
private void AddButtons() { List <GameObject> ll = new List <GameObject>(); for (int i = 0; i < itemList.Count; i++) { Ticket item = itemList[i]; // GameObject newButton = buttonObjectPool.GetObject(); GameObject obj = (GameObject)Instantiate(prefab); obj.transform.SetParent(contentPanel); ll.Add(obj); SampleButton sampleButton = obj.GetComponent <SampleButton>(); sampleButton.Setup(item, this); } }
private void AddButtons() { for (int i = 0; i < itemList.Count; i++) { Item item = itemList[i]; GameObject newButton = buttonObjectPool.GetObject(); newButton.transform.SetParent(contentPanel); newButton.transform.localScale = Vector3.one; newButton.transform.localPosition = Vector3.zero; newButton.transform.localRotation = Quaternion.AngleAxis(0f, new Vector3(0f, 15f, 0f)); SampleButton sampleButton = newButton.GetComponent <SampleButton>(); sampleButton.Setup(item, this); } }
public void AddButtons(int num) { //For No. of Songs for (int i = 0; i <= num - 1; i++) //For No. of Songs { print(genre); //Get Songs from Database using id Music temp = MusicDatabase.Instance.GetSong(i, genre); //Create button Object GameObject newButton = buttonObjectPool.GetObject(); newButton.transform.SetParent(contentPanel); //Set Button properties and info SampleButton sampleButton = newButton.GetComponent <SampleButton>(); sampleButton.Setup(temp, this); } }
public void AddButtons(List <Item> currList) { int i = 0; GameObject thisRow = null; //goes through the list and finds out how many items we have, //add buttons as needed for each of the items //and then call the setup function in sampleButton foreach (Item currItem in currList) { //Debug.Log (currItem.itemName); if (i % 2 == 0) { //Debug.Log ("making column"); GameObject newRow = RowObjectPool.GetObject(); newRow.transform.SetParent(contentPanel, false); thisRow = newRow; } GameObject newButton = buttonObjectPool.GetObject(); newButton.transform.SetParent(thisRow.transform, false); SampleButton sampleButton = newButton.GetComponent <SampleButton> (); sampleButton.Setup(currItem, this, this.control); i++; } //If there is a remainder if (i % 2 == 1) { GameObject newButton = buttonObjectPool.GetObject(); newButton.transform.SetParent(thisRow.transform, false); newButton.GetComponent <Button> ().enabled = false; foreach (Transform child in newButton.GetComponentsInChildren <Transform>()) { if (child.gameObject != newButton) { Destroy(child.gameObject); } } //newButton.Destroy (newButton.GetComponent<Image>); //newButton.GetComponent<Image> ().overrideSprite = blankButton; } }
void AddButtons() { for (int i = 0; i < itemList.Count; i++) { Item item = itemList[i]; GameObject newButton; if (buttonPool != null) { newButton = buttonPool.GetObject(); newButton.transform.SetParent(contentPanel); } else { newButton = Instantiate(buttonPrefab, contentPanel); } SampleButton sampleButton = newButton.GetComponent <SampleButton>(); sampleButton.Setup(item, this); } }
//------------------------------------------------------------------------- private void AddButtonsToCart() { for (int i = 0; i < cartList.Count; i++) { Item item = cartList[i].itemShop; GameObject newButton = cartObjectPool.GetObject(); newButton.transform.SetParent(cartPanel.transform); SampleButton sampleButton = newButton.GetComponent <SampleButton>(); for (int j = 0; j < shopItemList.Count; j++) { if (item.itemName == shopItemList[j].itemShop.itemName) { shopPositonItemPriceTemp = j; } } sampleButton.Setup(item, this, cartPanel, i, cartList[i]); cartButtonList.Add(sampleButton); cartButtonList[i].UpdateAmountCart(); } }
// Start is called before the first frame update void Start() { gameManager = GameObject.Find("GameManager"); gm = gameManager.GetComponent <GameManager>(); if (gameObject.tag == "inventory") { gold = gm.currency_p; } for (int i = 0; i < currentShopList.Count; i++) { Item item = currentShopList[i]; GameObject newButton = (GameObject)GameObject.Instantiate(prefab); newButton.transform.SetParent(contentPanel, false); SampleButton sampleButton = newButton.GetComponent <SampleButton>(); sampleButton.Setup(item, this); gameobjectShopList.Add(newButton); print(gameobjectShopList.Count); } RefreshDisplay(); }
// adds buttons for each item stored in our item list. // calls setup function of sample button private void AddButtons() { for (int i = 0; i < itemList.Count; i++) { Item item = itemList[i]; GameObject newButton = buttonObjectPool.GetObject(/*contentPanel*/); newButton.transform.SetParent(contentPanel); // will be automatically arranged correctly given the arrangements we set up in UI // RELEVANT // WORKAROUND FOR F*****G BUG THAT MESSES UP EVERYTHING // https://answers.unity.com/questions/1257149/scaling-dynamic-created-buttons.html newButton.transform.localScale = new Vector3(1f, 1f, 1f); // "Tell the button to set itself up..." // "So we are going to get a reference to that sample button script that we attache to our // sample button prefab" // YEAH... currently newButton stands for a gameobject... // SampleButton is about our kind of button for the game... // which is all part of the same thing but different components... SampleButton sampleButton = newButton.GetComponent <SampleButton>(); // reference to script... sampleButton.Setup(item, this); } }