Пример #1
0
 private void InitItem(FastGridItem item)
 {
     if (LuaInitItem != null)
     {
         LuaInitItem.Call(item);
     }
 }
Пример #2
0
    private void RefreshItem(FastGridItem item, FastGridItemData data)
    {
        if (LuaRefresh != null && item != null && data != null)
        {
            if (!RefreshAll && !AlwaysRefresh && item.ID == data.ID)
            {
                return;
            }

            if (item.ID != data.ID)
            {
                // 数据变化时,肯定隐藏被刷新掉的数据
                HideData(item.Data);
            }

            item.Data = data;
            RefreshItem(item.LuaUITable, data.LuaDataTable);
        }
    }
Пример #3
0
    private FastGridItem CreateGridItem(int uiIndex)
    {
        if (OriginalPrefab == null)
        {
            Debug.LogError("no prefab!");
            return(null);
        }

        if (initFlag == false)
        {
            initFlag = true;
        }

        GameObject objItem = GameObject.Instantiate(OriginalPrefab, Vector3.zero, Quaternion.identity, this.transform);

        objItem.SetActive(true);
        objItem.name = OriginalPrefab.name;

        RectTransform rect = objItem.GetComponent <RectTransform>();

        if (rect == null)
        {
            Debug.LogErrorFormat("{0} GetCompoinent<RectTransform> is null",
                                 objItem.gameObject.name);
        }
        else
        {
            //rect.anchorMin = Vector2.up;
            //rect.anchorMax = Vector2.up;
            rect.pivot = Vector2.up;
        }

        rect.SetAsFirstSibling();

        FastGridItem item = objItem.AddComponent <FastGridItem>();

        item.Index = uiIndex;

        InitItem(item);

        return(item);
    }
Пример #4
0
    private void SetGridItemSize(FastGridItem item)
    {
        if (item == null)
        {
            return;
        }

        RectTransform rect = item.GetComponent <RectTransform>();

        if (rect == null)
        {
            Debug.LogErrorFormat("{0} GetCompoinent<RectTransform> is null",
                                 item.gameObject.name);
            return;
        }

        // 设置items的大小
        if (!Changeable)
        {
            rect.sizeDelta = CellSize;
        }
    }