示例#1
0
        public void Awake()
        {
            instance    = this;
            thisObj     = gameObject;
            canvasGroup = thisObj.GetComponent <CanvasGroup>();
            if (canvasGroup == null)
            {
                canvasGroup = thisObj.AddComponent <CanvasGroup>();
            }

            canvasGroup.alpha = 0;
            thisObj.SetActive(false);
            thisObj.GetComponent <RectTransform>().anchoredPosition = new Vector3(0, 0, 0);

            fpsItem.Init();
            recticleSpreadDefaultSize = recticleSpreadRectT.sizeDelta;

            reloadProgressObj = imgReloadProgress.transform.parent.gameObject;
            reloadProgressObj.SetActive(false);

            UIItemCallback itemCallback = buttonFireObj.AddComponent <UIItemCallback>();

            itemCallback.SetDownCallback(this.OnFireButtonDown);
            itemCallback.SetUpCallback(this.OnFireButtonUp);

            buttonExit.Init();
        }
示例#2
0
 public void SetCallback(Callback enter = null, Callback exit = null, CallbackInputDependent down = null, CallbackInputDependent up = null)
 {
     itemCallback = rootObj.AddComponent <UIItemCallback>();
     itemCallback.SetEnterCallback(enter);
     itemCallback.SetExitCallback(exit);
     itemCallback.SetDownCallback(down);
     itemCallback.SetUpCallback(up);
 }
        void Start()
        {
            if (!AbilityManager.IsOn() || AbilityManager.GetAbilityCount() == 0)
            {
                thisObj.SetActive(false);
                return;
            }

            List <Ability> abList = AbilityManager.GetAbilityList();

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

                buttonList[i].imgIcon.sprite       = abList[i].icon;
                buttonList[i].imgHighlight.enabled = false;
                buttonList[i].label.text           = "";

                if (abList[i].usedRemained > 0)
                {
                    buttonList[i].label.text = abList[i].usedRemained.ToString();
                }
                //else buttonList[i].label.text="∞";

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


            tooltipRscItem.Init();


            butCancelCanvasG = butCancelObj.AddComponent <CanvasGroup>();
            OnAbilitySelectingTarget(false);

            UIItemCallback cancelCallback = butCancelObj.AddComponent <UIItemCallback>();

            cancelCallback.SetDownCallback(this.OnCancelAbilityButton);
            //cancelCallback.SetUpCallback(up);

            tooltipObj.SetActive(false);
        }