Ejemplo n.º 1
0
    void Start()
    {
        //设置展示数据内容
        int total = 10;

        for (int i = 0; i < total; i++)
        {
            GameObject obj = Instantiate(btnPrefab) as GameObject;
            obj.transform.SetParent(gameObject.transform);
            ButtonSelect btn = obj.GetComponent <ButtonSelect>();
            btn.SetTweenDelay(tweenDelay);

            btn.item.title        = "File" + (i + 1);
            btn.item.beanCost     = 50;
            btn.item.conType      = ContentType.GameWithPad;
            btn.item.introduction = "束带结发开始叫对方考虑,阿萨德发奖励卡加速度卡。洛手机打发了空间啊爱神,的箭法拉克加快速度就,付了款安静的弗兰克阿克苏的解放了看见卡上的副经理级!";
            btn.item.texture      = new GUITexture();

            btn.rectTrans.anchoredPosition = new Vector2(i * offset, 0f);
            btn.SetNotCurrent();
            buttons.Add(btn);
        }

        curIndex = 0;
        buttons[curIndex].SetCurrent();

        imgLeftMask.transform.SetParent(gameObject.transform);
        imgCenterMask.transform.SetParent(gameObject.transform);
        imgRightMask.transform.SetParent(gameObject.transform);
        imgLeftMask.enabled = false;
    }
Ejemplo n.º 2
0
    void MoveLeftOrRight(bool isLeft)
    {
        float flag = 1f;

        if (isLeft)
        {
            if (curIndex <= 0)
            {
                return;
            }
            curIndex -= 1;
        }
        else
        {
            if (curIndex >= buttons.Count - 1)
            {
                return;
            }
            flag      = -1f;
            curIndex += 1;
        }

        //调整显示左右遮罩
        imgLeftMask.enabled = true;
        if (curIndex <= 0)
        {
            imgLeftMask.enabled = false;
        }
        imgRightMask.enabled = true;
        if (curIndex >= buttons.Count - 1)
        {
            imgRightMask.enabled = false;
        }

        //渐变遮罩
        TweenMaskAlpha(imgLeftMask, 0.7f, 0.5f);
        TweenMaskAlpha(imgCenterMask, 0.85f, 2.0f);
        TweenMaskAlpha(imgRightMask, 0.7f, 0.5f);

        for (int i = 0; i < buttons.Count; i++)
        {
            ButtonSelect btn = buttons[i];
            btn.TweenTo(btn.rectTrans.anchoredPosition.x + offset * flag);
            if (i == curIndex)
            {
                btn.SetCurrent();
            }
            else
            {
                if (btn.isCurrent)
                {
                    btn.SetNotCurrent();
                }
            }
        }
    }