我希望使用Unity3d创建一款Android游戏。这个游戏有一个可滑动的升级列表。我使用以下代码创建了它,但是当我在触摸屏上移动手指时,列表滚动起来很困难,并且会跳跃。我希望它能像Android效果一样平稳地滚动。
scrollPosition1 = GUI.BeginScrollView(Rect (0,400,Screen.width,175),
scrollPosition1, Rect (0, 0, 650, 0));
// touch screen
if(Input.touchCount==1 &&
Screen.height -Input.GetTouch(0).position.y > 450 - scrollPositionHome.y &&
Screen.height - Input.GetTouch(0).position.y < 600 - scrollPositionHome.y)
{
var touchDelta2 : Vector2 = Input.GetTouch(0).deltaPosition;
scrollPosition1.x +=touchDelta2.x;
}
for (i=0;i < ImgSliderProducts.Length;i++)
{
GUI.DrawTexture(Rect(20+(i* 100),10,100,100),
ImgSliderProducts[i],ScaleMode.ScaleToFit,true);
}
GUI.EndScrollView();