Ejemplo n.º 1
0
    private void SelectedCardItem(int index)
    {
        if (currentSelectedIndex == index)
        {
            return;
        }

        currentSelectedIndex = index;

        SkinCardItem item = skinCardList[index];

        if (onCenter != null)
        {
            onCenter(item);
        }
    }
Ejemplo n.º 2
0
    public void Refresh(int number)
    {
        centerPosList.Clear();
        skinCardList.Clear();

        float centerPosX;

        for (int i = 0; i < number; i++)
        {
            centerPosX = firstPosDistance - (itemWidth + group.spacing) * i;
            centerPosList.Add(centerPosX);

            SkinCardItem skinCardItem = skinCardGroup.GetChild(i).GetComponent <SkinCardItem> ();
            skinCardList.Add(skinCardItem);

            skinCardItem.onClickEvent = OnClickSkinCardItemCallBack;
        }

        //Used this code when Card get from server
        //targetPos = FindClosestPos ( firstPosDistance );
        //centering = true;
    }
Ejemplo n.º 3
0
    void Update()
    {
        if (centering)
        {
            Vector3 v = skinCardGroup.localPosition;

            v.x = Mathf.Lerp(skinCardGroup.localPosition.x, targetPos, centerSpeed * Time.deltaTime);

            skinCardGroup.localPosition = v;

            if (Mathf.Abs(skinCardGroup.localPosition.x - targetPos) < 0.01f)
            {
                centering = false;
            }
        }

        for (int i = 0; i < skinCardList.Count; i++)
        {
            SkinCardItem item     = skinCardList[i];
            float        distance = Mathf.Abs(skinCardGroup.localPosition.x - centerPosList[i]);
            float        scale    = scaleCurve.Evaluate(distance);
            item.UpdateScrollViewItems(scale);
        }
    }