public void Refresh()
    {
        Debug.Log("===================Refresh=================");
        for (int i = 0; i < Rect.childCount; i++)
        {
            Transform tran = Rect.GetChild(i);
            if (ItemsOld.Contains(tran))
            {
                continue;
            }
            if (!tran.gameObject.activeInHierarchy)
            {
                continue;
            }

            UI_Control_ScrollFlow_Item item = tran.GetComponent <UI_Control_ScrollFlow_Item>();
            if (item != null)
            {
                Items.Add(item);
                item.Init(this);
                item.Drag(StartValue + (Items.Count - 1) * AddValue);
                if (item.v - 0.5 < 0.05f)
                {
                    Current = item;
                }
            }
        }
        if (Items.Count < 5)
        {
            switch (Items.Count)
            {
            case 1:
            case 2:
                VMax = 0.7f;
                VMin = 0.3f;
                break;

            case 3:
                VMax = 0.9f;
                VMin = 0.1f;
                break;

            case 4:
                VMax = 1.1f;
                VMin = -0.1f;
                break;
            }
        }
        else
        {
            VMax = 0.9f + (Items.Count - 5) * AddValue;
            VMin = 0.1f;
        }
        if (MoveEnd != null)
        {
            MoveEnd(Current);
        }
        Check(1);
        for (int i = 0; i < Items.Count; i++)
        {
            Items[i].Refresh();
        }
        ItemsOld.Clear();
    }
コード例 #2
0
    public void Refresh()
    {
        Debug.Log("===================Refresh=================");
        for (int i = 0; i < Rect.childCount; i++)
        {
            Transform tran = Rect.GetChild(i);
            if (ItemsOld.Contains(tran))
            {
                continue;
            }
            if (!tran.gameObject.activeInHierarchy)
            {
                continue;
            }

            UI_Control_ScrollFlow_Item item = tran.GetComponent <UI_Control_ScrollFlow_Item>();
            if (item != null)
            {
                Items.Add(item);
                item.Init(this);
                item.Drag(StartValue + (Items.Count - 1) * (1.0f / nCount));
                if (item.v - 0.5 < 0.05f)
                {
                    Current   = item;
                    firstitem = Current;
                    centerX   = Current.transform.localPosition.x;
                    height    = Current.GetComponent <RectTransform>().sizeDelta.y;

                    foreach (UI_Control_ScrollFlow_Item t in Items)
                    {
                        t.GetComponent <Image>().sprite =
                            t.GetComponent <UI_Control_ScrollFlow_Item>().Norimg;
                    }

                    Current.GetComponent <Image>().sprite =
                        Current.GetComponent <UI_Control_ScrollFlow_Item>().Preimg;
                    //item.GetComponent<uicontrolScrollViewItem>().Selected();
                }
                if (Items.Count == 2)
                {
                    spacingx = Mathf.Abs(Items[0].transform.localPosition.x - Items[1].transform.localPosition.x);
                    //Debug.LogError(spacingx);
                }
            }

            //Debug.Log(Items.Count.ToString() + "___" + item.name);
        }

        while (Items.Count < nCount)
        {
            m_nCount--;
        }

        VMax = 0.85f + (Items.Count - nCount) * (1.0f / nCount);
        VMin = 0.15f;


        Debug.Log("ddddd");
        if (MoveEnd != null)
        {
            MoveEnd(Current);
        }
        Check(1);
        for (int i = 0; i < Items.Count; i++)
        {
            Items[i].Refresh();
        }
        ItemsOld.Clear();
    }