0
我有項目列表和這個列表有滾動條,在Windows滾動條工作不錯,但在Android觸摸屏滾動條是非常錫和用戶無法觸摸滾動條,我希望用戶可以滾動列表只有列表上的觸摸。 TNX。如何在Android中使用觸摸屏在Unity3d中滾動列表?
我有項目列表和這個列表有滾動條,在Windows滾動條工作不錯,但在Android觸摸屏滾動條是非常錫和用戶無法觸摸滾動條,我希望用戶可以滾動列表只有列表上的觸摸。 TNX。如何在Android中使用觸摸屏在Unity3d中滾動列表?
我找到了。必須拿到觸摸屏pos並設置一個移動範圍。
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;
}
GUI.skin.font = fnt;
style.normal.textColor = Color.black;
style.alignment = TextAnchor.MiddleRight;
for (i=0;i < ImgSliderProducts.Length;i++)
{
GUI.DrawTexture(Rect(20+(i* 100),10,100,100), ImgSliderProducts[i],ScaleMode.ScaleToFit,true);
}
GUI.EndScrollView();