Пример #1
0
    //void Start()
    //{
    //    Init(Hero.singlton.skills, Hero.singlton);
    //}

    //void Init(List<Skill> skills, Unit unit)
    //{
    //    foreach (var skill in skills)
    //        if (skill.drawUIButton)
    //            mainButton = CreateButton(skill, unit);
    //}

    SkillButton CreateButton(Skill skill, Unit unit)
    {
        SkillButton button = Instantiate(buttonPref, rect);

        button.Init(unit, skill);
        return(button);
    }
Пример #2
0
        void InitUI()
        {
            skillButtons = new SkillButton[skillCount];

            for (int i = 0; i < skillCount; i++)
            {
                SkillButton newButton = skillPanel.transform.GetChild(i).GetComponent <SkillButton>();
                newButton.Init();
                skillButtons[i] = newButton;
            }

            itemButtons = new ItemButton[itemCount];
            for (int i = 0; i < itemCount; i++)
            {
                ItemButton newButton = itemPanel.transform.GetChild(i).GetComponent <ItemButton>();
                newButton.Init();
                itemButtons[i] = newButton;
            }
            UpdateItemButtons();
        }
Пример #3
0
    void OnEnable()
    {
        var mc = GameObject.Find("MainCanvas");
        toolTipObj = mc.transform.Find("SkillPanel/ToolTip").gameObject;

        // Gets Reference to the ToolTip texts.
        toolTipDscrpt = toolTipObj.transform.FindChild("Description").gameObject.GetComponent<Text>();

        toolTipFstLbl = toolTipObj.transform.FindChild("FirstLabel").gameObject.GetComponent<Text>();
        toolTipSndLbl = toolTipObj.transform.FindChild("SecondLabel").gameObject.GetComponent<Text>();
        toolTipThdLbl = toolTipObj.transform.FindChild("ThirdLabel").gameObject.GetComponent<Text>();

        toolTipFstAtt = toolTipObj.transform.FindChild("FirstAttribute").gameObject.GetComponent<Text>();
        toolTipSndAtt = toolTipObj.transform.FindChild("SecondAttribute").gameObject.GetComponent<Text>();
        toolTipThdAtt = toolTipObj.transform.FindChild("ThirdAttribute").gameObject.GetComponent<Text>();

        LastUse = float.MinValue;

        // CreateUI
        if (SkillButtonPrefab != null)
        {
            var skillBar = GameObject.Find("SkillBar");
            var button = Instantiate(SkillButtonPrefab);
            var showCallback = button.GetComponent<EventTrigger>().triggers.First(a => a.eventID == EventTriggerType.PointerEnter).callback;
            showCallback.AddListener(ShowToolTip);

            var hideCallback = button.GetComponent<EventTrigger>().triggers.First(a => a.eventID == EventTriggerType.PointerExit).callback;
            hideCallback.AddListener(HideToolTip);

            if (addToSkillBar)
            {
                button.transform.SetParent(skillBar.transform, false);
            }

            SkillBtnScript = button.GetComponent<SkillButton>();
            SkillBtnScript._skill = this;
            SkillBtnScript._skillBar = GetComponent<SkillBar>();
            SkillBtnScript.Init();
            //HideToolTip();
        }
    }