示例#1
0
    private void AddElement(List <ListUpgrade> types)
    {
        List <RectTransform> rectList = new List <RectTransform>();

        for (int i = 0; i < types.Count; i++)
        {
            int capture           = i;
            GUIInteractableIcon e = Instantiate(Element);
            rectList.Add(e.transform as RectTransform);
            e.Placeholder.text = types[i].ToString().InsertSpace();
            e.InteractableChange(SyncData.CurrentBaseUpgrade[types[capture]].Level > 0);
            e.OnClickEvents += delegate
            {
                OnSelected(types[capture]);
            };

            elementCount = (elementCount + 1) % ColumnNum;
            if (elementCount == 0 || types.Count - 1 == i)
            {
                curRow.Add(rectList);
                rectList.Clear();

                curRow             = Instantiate(rowLayoutPrefab, ScrollView.Content);
                curRow.ElementSize = ElementSize;
                rows.Add(curRow);
            }
        }
    }
示例#2
0
    protected override void Init()
    {
        if (rows == null)
        {
            rows = new List <GUIHorizontalGrid>();
        }
        if (curRow == null)
        {
            curRow             = Instantiate(rowLayoutPrefab, ScrollView.Content);
            curRow.ElementSize = ElementSize;
            rows.Add(curRow);
        }

        elementCount = 0;
        List <ListUpgrade> types = new List <ListUpgrade>()
        {
            ListUpgrade.Soldier,
            ListUpgrade.TraninedSolider,
            ListUpgrade.ForbiddenGuard,
            ListUpgrade.Heroic
        };

        AddElement(types);
    }
示例#3
0
 protected override void OnEnable()
 {
     base.OnEnable();
     Owner = (GUIHorizontalGrid)target;
     size  = Owner.ElementSize;
 }