unity Scroll View回滚到顶部

unity Scroll View回滚到顶部

回到滚动列表顶部的方法: //找到节点对象 protected override void InitUIInfo() { tran\_ScrollView = FindChild(this.gameObject, "ScrollView"); tran\_Viewport = FindChild(tran\_ScrollView.gameObject, "Viewport"); tran\_Content = FindChild(tran\_Viewport.gameObject, "Content"); } //回到顶部的方法 private void GoTop() { localPos = tran\_Content.localPosition; localPos.y = 0; tran\_Content.localPosition = localPos; //tran\_Content.localPosition.x = 0;不能直接赋值 } 另一种回到顶部的方法: Scroll View回滚到顶部:直接赋值或者自己写个Vector3.Lerp()差值移动,NGUI也有: scroll.content.DOLocalMove(Vector3.zero, 0.2f);