将滚动条的按钮居中

时间:2018-10-08 20:56:33

标签: user-interface unity3d scrollbar

我尝试使滚动条中的按钮数组居中,但是只有第一个元素更新位置,当我按下另一个按钮时,只有第一个按钮是move,知道吗?

public void CenterBets1()
{
    Debug.Log("click");

    for (int i = 0; i < bets.Count; i++)
    {
        if (bets[i].gameObject.tag == "ContainerTag" && bets[i].gameObject.name == "Container (1)" && bets[i].editorValue == 10)
        {
            Debug.Log("container click 1");

            betContent.offsetMin = new Vector2( -(contentSize * (betContent.anchorMin.x + ((betContent.anchorMax.x  - betContent.anchorMin.x) * 0.5f) * contentSize)), 0);
            betContent.offsetMax = new Vector2(contentSize * (betContent.anchorMin.x + ((betContent.anchorMax.x - betContent.anchorMin.x) * 0.5f) * contentSize), 0);

            Debug.Log("anchor max: " + betContent.anchorMax.x + " anchor min: " + betContent.anchorMin.x);

            Debug.Log("offset max: " + betContent.offsetMax + " offset min: " + betContent.offsetMin);

        }
    }

}

0 个答案:

没有答案