我想在android中用触摸屏滚动我的滑块,我有这个代码:
// for scroll
var scrollPosition : Vector2 = Vector2.zero;
//label style
var touch = Input.touches[0];
function OnGUI() {
windowMain = GUI.Window(1, Rect(0,0,Screen.width,Screen.height), WindowFunctionMain, " ");
}
function WindowFunctionMain (windowID : int) {
scrollPosition = GUI.BeginScrollView(Rect (0,Screen.height/2,Screen.width,Screen.height/4+20),scrollPosition, Rect (0, 0, 650, 0));
if(touch.phase == TouchPhase.Moved)
scrollPosition = scrollPosition + touch.deltaPosition.y;
for (var i=0;i < ImgSliderProducts.Length;i++)
{
GUI.DrawTexture(Rect(20+(i* 100),10,100,100), ImgSliderProducts[i],ScaleMode.ScaleToFit,true);
}
GUI.EndScrollView();
但在这一行有错误:scrollPosition = scrollPosition + touch.deltaPosition.y;
运算符“+”不能与“UnityEngine.Vector2”类型的左侧和“float”类型的右侧一起使用。我怎么解决这个问题 ?TNX。