CreateItem() public method

Instantiates a new list item based on the prefab to clone, adds it to the end of the list and returns a reference to it. NOTE: The prefab/GameObject is required to have a component that implements IUIListObject. NOTE: For proper appearance, list items should each be of uniform width when the list is vertical, and of uniform height when the list is horizontal. Besides that, list items can vary in size.
public CreateItem ( GameObject prefab ) : IUIListObject
prefab GameObject GameObject/Prefab which is to be instantiated and added to the end of the list.
return IUIListObject
示例#1
0
    IUIListObject NewChild(string name, string goName)
    {
        IUIListObject newItem = list.CreateItem(childPrefab, name);

        newItem.gameObject.name = goName;
        UIButton btn = newItem.gameObject.GetComponent <UIButton>();

        if (btn != null)
        {
            btn.AddInputDelegate(ItemsInputDelegate);
        }
        return(newItem);
    }
示例#2
0
    void AddNewItem(string text)
    {
        // Instantiates a new item from the item object and
        // sets any attached text object to "Level 1":

        IUIListObject newItem    = list.CreateItem(chatItem);
        SpriteText    spriteText = newItem.gameObject.transform.FindChild("text").gameObject.GetComponent <SpriteText>();

        if (spriteText != null)
        {
            spriteText.Text = UIString.Instance.ParserString_Runtime(text);
        }

        UISystem.Instance.AddHollowWindow(newItem.gameObject);

        list.ScrollToItem(newItem, 0.0f, EZAnimation.EASING_TYPE.Linear);
        if (list.UnviewableArea > 0)
        {
            list.slider.Hide(false);
        }
        else
        {
            list.slider.Hide(true);
        }
    }
示例#3
0
    void Start()
    {
        int itemsPerPage  = worldPage.GetComponent <ItemsPage>().maximum;
        int numberOfPages = Mathf.CeilToInt((float)worlds.Length / (float)itemsPerPage);

        for (int i = 0; i < numberOfPages; i++)
        {
            worldsScroll.CreateItem(worldPage);
            ItemsPage page = worldsScroll.GetItem(worldsScroll.Count - 1).gameObject.GetComponent <ItemsPage>();
            for (int j = 0; j < page.worlds.Length; j++)
            {
                if ((i * itemsPerPage + j) > worlds.Length - 1)
                {
                    //Debug.Log("o item " + (i*itemsPerPage+j) + " foi desativado");
                    page.worlds[j].gameObject.SetActive(false);
                }
                else
                {
                    page.worlds[j].properties = worlds[i * itemsPerPage + j];
                    page.worlds[j].manager    = this;
                }
            }
        }

        /*foreach(WorldProperties p in worlds)
         * {
         *      worldsScroll.CreateItem(worldPrefab);
         *      World newWorld = worldsScroll.GetItem(worldsScroll.Count-1).gameObject.GetComponent<World>();
         *      newWorld.properties = p;
         *      newWorld.manager = this;
         * }*/
    }
示例#4
0
    void CreateContainer(IJSonObject item)
    {
        containerCounter++;
        GameObject g = scroll.CreateItem(rankingsPrefab).gameObject;

        g.transform.FindChild("Name").GetComponent <SpriteText>().Text = item["name"].StringValue;
        g.transform.FindChild("Time").GetComponent <SpriteText>().Text = "Time: " + item["time"].StringValue;
        //g.transform.FindChild("Deaths").GetComponent<SpriteText>().Text = "Deaths: " + item["deaths"].StringValue;
        g.transform.FindChild("Matches").GetComponent <SpriteText>().Text = "Tries: " + item["tries"].StringValue;
        g.transform.FindChild("Ranking").GetComponent <SpriteText>().Text = containerCounter.ToString();
        if (!item["deaths"].IsNull)
        {
            switch (item["deaths"].Int32Value)
            {
            case 0:
                g.transform.FindChild("Star1").gameObject.SetActive(true);
                g.transform.FindChild("Star2").gameObject.SetActive(true);
                g.transform.FindChild("Star3").gameObject.SetActive(true);
                break;

            case 1:
                g.transform.FindChild("Star1").gameObject.SetActive(true);
                g.transform.FindChild("Star2").gameObject.SetActive(true);
                break;

            case 2:
                g.transform.FindChild("Star1").gameObject.SetActive(true);
                break;
            }
        }
    }
    void RefreshList()
    {
        RefreshButtons();

        _saveScrollList.ClearList(true);
        foreach (string levelName in LevelDataManager.instance.SaveList)
        {
            IUIListObject listObject = _saveScrollList.CreateItem(_saveListItemPrefab.gameObject, levelName);
            listObject.SetInputDelegate(HandleHandleEZInputDelegate);
        }
    }
示例#6
0
 // Use this for initialization
 public override void Start()
 {
     base.Start();
     if (Application.loadedLevel == 0)
     {
         for (var i = 0; i < 10; i++)
         {
             var newItem = scrollList.CreateItem(listItemPrefab);
             scrollList.AddItem(newItem);
         }
         scrollList.PositionItems();
         scrollList.snap = true;
         scrollList.SetInputDelegate(OnNextButtonPress);
     }
 }
示例#7
0
    void AddNewItem(string text)
    {
        // Instantiates a new item from the item object and
        // sets any attached text object to "Level 1":
        if (list.Count >= 1)
        {
            IUIListObject lastItem = list.GetItem(list.Count - 1);
            if (lastItem.Text == text)
            {
                return;
            }
        }

        IUIListObject newItem = list.CreateItem(textPrefab, text);

        UISystem.Instance.AddHollowWindow(newItem.gameObject);

        list.ScrollToItem(newItem, 0.5f, EZAnimation.EASING_TYPE.Linear);
    }
示例#8
0
	private void _CreateListItem(UIScrollList scrollList)
	{
		UIListItem chatItem = scrollList.CreateItem( chatListItem) as UIListItem;
		chatItem.collider.enabled = false;
		chatItem.width = scrollList.viewableArea.x;
		chatItem.spriteText.maxWidth = scrollList.viewableArea.x;
		chatItem.CalcSize();
		AsLanguageManager.Instance.SetFontFromSystemLanguage( chatItem.spriteText);
		chatItem.Text = "";
	}
示例#9
0
    void AddActivityInfoToList()
    {
        List.ClearList(true);

        CultureInfo ci;

        ci = new CultureInfo("de-DE");
        DateTime time;

        int nCount = CDataPool.Instance.Campaign_GetCampaignCount();

        for (int i = 0; i < nCount; i++)
        {
            _DBC_ACTIVITY_INFO info = CDataPool.Instance.Campaign_GetCampaignInfo(i);
            IUIListObject      item = List.CreateItem(listItem);

            item.Data            = (short)info.nID;
            item.gameObject.name = item.Data.ToString();
            item.gameObject.SetActiveRecursively(true);
            ActionButton action = item.gameObject.GetComponentInChildren <ActionButton>();
            if (action != null)
            {
                action.SetIcon(info.szActivityIcon);
            }
            SpriteText[] texts = item.gameObject.GetComponentsInChildren <SpriteText>();
            for (int j = 0; j < texts.Length; j++)
            {
                if (texts[j].gameObject.name == "Name")
                {
                    texts[j].Text = info.szActivityName;
                }
                else if (texts[j].gameObject.name == "Time")
                {
                    if (info.IsDayActivity == 1)                    //全天型活动
                    {
                        texts[j].Text = "全天";
                    }
                    else
                    {
                        if (DateTime.TryParse(info.StartTime, out time))
                        {
                            texts[j].Text = time.ToString("HH:mm", ci);
                        }
                        if (DateTime.TryParse(info.EndTime, out time))
                        {
                            texts[j].Text += "-" + time.ToString("HH:mm", ci);
                        }
                    }
                }
            }
            UIButton[] btns = item.gameObject.GetComponentsInChildren <UIButton>();
            for (int k = 0; k < btns.Length; k++)
            {
                if (btns[k].gameObject.name == "Join")
                {
                    btns[k].AddInputDelegate(OnJoinActivityClicked);
                }
            }

            CurTime.Text = DateTime.Now.ToString("HH:mm");

            item.gameObject.SetActiveRecursively(false);
        }
    }
示例#10
0
    void UpdateSkill()
    {
        if (!gameObject.active)
        {
            return;
        }

        ResetUI();

        if (tabMode == TAB_MODE.TAB_SELFXINFA)
        {
            int           num         = CActionSystem.Instance.GetSkillActionNum();
            int           nXinfaIndex = -1;
            IUIListObject listItem    = null;
            for (int i = 0; i < num; i++)
            {
                CActionItem_Skill skill = CActionSystem.Instance.EnumAction(i, ActionNameType.Skill) as CActionItem_Skill;
                if (skill != null && (skill.GetXinfaID() >= SCLIENT_SKILLCLASS.XINFATYPE_JINGJIEBEGIN && skill.GetXinfaID() < SCLIENT_SKILLCLASS.XINFATYPE_SKILLBENGIN))
                {
                    nXinfaIndex++;
                    int nOffset = nXinfaIndex % 3;
                    if (nOffset == 0)
                    {
                        listItem = list.CreateItem(itemPrefab);
                        listItem.gameObject.name = "XinfaListItem" + nXinfaIndex;
                        for (int j = 0; j < 3; j++)
                        {
                            listItem.gameObject.transform.FindChild("Item" + j).gameObject.SetActiveRecursively(false);
                        }
                    }
                    GameObject item = listItem.gameObject.transform.FindChild("Item" + nOffset).gameObject;
                    item.SetActiveRecursively(true);
                    ActionButton skillAction = item.GetComponentInChildren <ActionButton>();
                    if (skillAction != null)
                    {
                        skillAction.SetActionItemByActionId(skill.GetID());
                        skillAction.DisableDrag();
                        skillAction.EnableDoAction = false;
                    }
                    UIButton bg = item.transform.FindChild("Bg").gameObject.GetComponent <UIButton>();
                    if (bg != null)
                    {
                        bg.SetInputDelegate(handlerInput);
                    }

                    SpriteText txt = item.transform.FindChild("NameLabel").gameObject.GetComponent <SpriteText>();
                    if (txt != null)
                    {
                        txt.Text = skill.GetName() + "\n" + "等级:" + skill.GetSkillLevel();
                    }

                    UIButton levelBtn = item.transform.FindChild("LevelUp").gameObject.GetComponent <UIButton>();
                    if (levelBtn != null)
                    {
                        levelBtn.SetInputDelegate(levelUpInputDelegate);
                        //LogManager.LogWarning("Set Delegate : " + levelBtn.gameObject.name);
                    }


                    SCLIENT_SKILLCLASS skillClass = CObjectManager.Instance.getPlayerMySelf().GetCharacterData().Get_SkillClass(skill.GetXinfaID());
                    //升级可操作
                    string error;
                    if (!CDataPool.Instance.isCanSkillLevelUp(skillClass.m_pDefine.nID, skillClass.m_nLevel + 1, out error))
                    {
                        item.transform.FindChild("LevelUp").gameObject.GetComponent <UIButton>().controlIsEnabled = false;
                        //toolText[showIndex] = UIString.Instance.ParserString_Runtime(error);
                    }
                    else
                    {
                        item.transform.FindChild("LevelUp").gameObject.GetComponent <UIButton>().controlIsEnabled = true;
                        //toolText[showIndex] = null;
                    }
                }
            }
        }
        else if (tabMode == TAB_MODE.TAB_PETXINFA)
        {
            //int num = CActionSystem.Instance.GetSkillActionNum();
            ////LogManager.LogWarning("Skill count = " + num);
            //int showIndex = 0;
            //for (int i = 0; i < num; i++)
            //{
            //    CActionItem_Skill skill = CActionSystem.Instance.EnumAction(i, ActionNameType.Skill) as CActionItem_Skill;


            //    if (showIndex >= buttons.Count) break;

            //    //超过51不属于普通技能
            //    if (skill != null && (skill.GetXinfaID() == -1 && skill.GetIDTable() < 51))
            //    {
            //        // LogManager.LogWarning("Xinfa = " + skill.GetXinfaID() + "skill = " + skill.GetDefineID() + "index=" + i);
            //        //这里可能有问题
            //        items[showIndex].SetActiveRecursively(true);

            //        buttons[showIndex].UpdateItemFromAction(skill);
            //        buttons[showIndex].EnableDrag();
            //        buttons[showIndex].EnableDoAction = true;

            //        //update text
            //        txtNames[showIndex].Text = skill.GetName();
            //        txtLevels[showIndex].Text = "等级:" + skill.GetSkillLevel();

            //        levelUpBtns[showIndex].gameObject.SetActiveRecursively(false);

            //        showIndex++;
            //    }
            //}
        }
        if (list.UnviewableArea > 0)
        {
            list.slider.Hide(false);
        }
        else
        {
            list.slider.Hide(true);
        }
    }
示例#11
0
 public IUIListObject CreateItem(GameObject ObjectItem)
 {
     //ObjectItem.transform.position	=	new Vector3(PosX,PosY,PosZ);
     return(ScrollList.CreateItem(ObjectItem));
 }