-2

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。

4

1 に答える 1