Example #1
0
        void Start()
        {
            if (BuildManager.GetInstance() == null)
            {
                return;
            }

            List <UnitTower> towerList = BuildManager.GetTowerList();

            for (int i = 0; i < towerList.Count; i++)
            {
                if (i == 0)
                {
                    buttonList[0].Init();
                }
                else if (i > 0)
                {
                    buttonList.Add(UIButton.Clone(buttonList[0].rootObj, "BuildButton" + (i + 1)));
                }

                buttonList[i].imgIcon.sprite       = towerList[i].iconSprite;
                buttonList[i].imgHighlight.enabled = false;

                if (UIMainControl.InTouchMode())
                {
                    buttonList[i].SetCallback(null, null, this.OnTowerButton, null);
                }
                else
                {
                    buttonList[i].SetCallback(this.OnHoverButton, this.OnExitButton, this.OnTowerButton, null);
                }
            }

            if (!BuildManager.UseDragNDrop())
            {
                canvasGroup.alpha   = 0;
                rectT.localPosition = new Vector3(0, 99999, 0);
            }

            if (!BuildManager.UseDragNDrop() && UIMainControl.UsePieMenu())
            {
                layoutGroup.enabled = false;
                tooltipObj.transform.localPosition -= new Vector3(0, 60, 0);
            }
            else
            {
                layoutGroup.enabled = true;
            }


            List <Rsc> rscList = ResourceManager.GetResourceList();

            for (int i = 0; i < rscList.Count; i++)
            {
                if (i == 0)
                {
                    tooltipRscItemList[0].Init();
                }
                else
                {
                    tooltipRscItemList.Add(UIObject.Clone(tooltipRscItemList[0].rootObj, "Rsc" + (i + 1)));
                }

                tooltipRscItemList[i].imgRoot.sprite = rscList[i].icon;
                tooltipRscItemList[i].label.text     = rscList[i].value.ToString();
            }

            if (!BuildManager.UseDragNDrop())
            {
                butCancelObj.SetActive(false);
            }
            else
            {
                butCancelCanvasG = butCancelObj.AddComponent <CanvasGroup>();
                butCancelObj.transform.SetAsLastSibling();
                OnDragNDrop(false);
            }

            tooltipObj.SetActive(false);
        }