Unity UGUI ScrollView滑动到指定位置

using UnityEngine;
using UnityEngine.UI;
public class Test : MonoBehaviour
{
    private ScrollRect sc;

    private void Start()
    {
        sc = GetComponent();
    }
    
    /// 
    /// 设置Rect位置
    /// 
    /// 取值范围0-1 0底部或者最左边  1顶部或者最右边
    /// 是否设置Vertical
    public void SetRectPos(float value, bool isvertical)
    {
        if(sc)
        if (isvertical)
            sc.verticalNormalizedPosition = value;
        else
            sc.horizontalNormalizedPosition = value;
    }
}

你可能感兴趣的:(Unity,unity,c#,游戏引擎)