using UnityEngine;
using UnityEngine.UI;
public class Test : MonoBehaviour
{
private ScrollRect sc;
private void Start()
{
sc = GetComponent<ScrollRect>();
}
/// <summary>
/// 设置Rect位置
/// </summary>
/// <param name="value">取值范围0-1 0底部或者最左边 1顶部或者最右边</param>
/// <param name="isvertical">是否设置Vertical</param>
public void SetRectPos(float value, bool isvertical)
{
if(sc)
if (isvertical)
sc.verticalNormalizedPosition = value;
else
sc.horizontalNormalizedPosition = value;
}
}
Unity UGUI ScrollView滑动到指定位置
最新推荐文章于 2024-06-16 02:08:27 发布