コード例 #1
0
ファイル: ShopScrollList.cs プロジェクト: Hyotni/BearsWeekend
    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();
            });
        }
    }
コード例 #2
0
    private void AddButtons()
    {
        if (itemList != null && itemList.Count > 0)
        {
            foreach (var item in itemList)
            {
                ItemManager.Item itemInfo  = ItemManager.instance.items [item.itemID];               //itemList.Count - 1];
                GameObject       newToggle = toggleObjectPool.GetObject();
                newToggle.transform.SetParent(contentPanel);
                SampleButton sampleButton = newToggle.GetComponent <SampleButton>();
                sampleButton.Setup(itemInfo, this);

                if (item.itemID < 6)
                {
                    //Possible error
                    if (UIController.instance.GetStoreScript() && !UIController.instance.GetStoreScript().GetOwnedFormByID(item.itemID))
                    {
                        UIController.instance.SetToggleInteractive(false);
                        sampleButton.GetComponent <Toggle> ().interactable = false;
                        sampleButton.GetComponent <Toggle> ().isOn         = false;
                        sampleButton.GetComponent <Toggle> ().interactable = true;
                        UIController.instance.SetToggleInteractive(true);
                    }
                    else
                    {
                        UIController.instance.SetToggleInteractive(true);
                        sampleButton.GetComponent <Toggle> ().interactable = true;
                        sampleButton.GetComponent <Toggle> ().isOn         = true;
                        sampleButton.GetComponent <Toggle> ().interactable = true;
                        UIController.instance.SetToggleInteractive(true);
                    }
                }                 /*else {
                                   *    if (!UIController.instance.GetStoreScript ().GetOwnedHatByID (item.itemID)) {
                                   *            UIController.instance.SetToggleInteractive (false);
                                   *            sampleButton.GetComponent<Toggle> ().interactable = false;
                                   *            sampleButton.GetComponent<Toggle> ().isOn = false;
                                   *            sampleButton.GetComponent<Toggle> ().interactable = true;
                                   *            UIController.instance.SetToggleInteractive (true);
                                   *    } else {
                                   *            UIController.instance.SetToggleInteractive (true);
                                   *            sampleButton.GetComponent<Toggle> ().interactable = true;
                                   *            sampleButton.GetComponent<Toggle> ().isOn = true;
                                   *            sampleButton.GetComponent<Toggle> ().interactable = true;
                                   *            UIController.instance.SetToggleInteractive (true);
                                   *    }
                                   *    AddFancyButtons (sampleButton, item.itemID);
                                   * }*/
                                  //if (item.itemID >= 6) {

                //AddFancyButtons (sampleButton, itemList [i].itemID);
                //} else {
                //if (sampleButton.tag == "Untagged") {
                //sampleButton.tag = "balloonForm";
                //}
                //}
                sampleButton.transform.localScale    = new Vector3(1, 1, 1);
                sampleButton.transform.localPosition = new Vector3(sampleButton.transform.localPosition.x, sampleButton.transform.localPosition.y, 0);
            }

            /*for (int i = 0; i < itemList.Count; i++) {
             *      ItemBought item = itemList [i];
             *      //Debug.Log ("ITEM ID: " + item.itemID);
             *      ItemManager.Item itemInfo = ItemManager.instance.items [item.itemID];//itemList.Count - 1];
             * GameObject newToggle = toggleObjectPool.GetObject();
             *      newToggle.transform.SetParent(contentPanel);
             * SampleButton sampleButton = newToggle.GetComponent<SampleButton>();
             *      //Debug.Log ("ID OF BUTTON: " + sampleButton.tag);
             *      sampleButton.Setup(itemInfo, this);
             *
             *      if (itemList [i].itemID >= 6) {
             *              //AddFancyButtons (sampleButton, itemList [i].itemID);
             *      } else {
             *      //if (sampleButton.tag == "Untagged") {
             *              //sampleButton.tag = "balloonForm";
             *      }
             *      //}
             * sampleButton.transform.localScale = new Vector3(1, 1, 1);
             * sampleButton.transform.localPosition = new Vector3(sampleButton.transform.localPosition.x, sampleButton.transform.localPosition.y, 0);
             * }*/
        }
    }