小编xwp*_*ram的帖子

如何在unity3d中创建触摸屏android滚动?

我想用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(); 
Run Code Online (Sandbox Code Playgroud)

android unity-game-engine unityscript

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

android ×1

unity-game-engine ×1

unityscript ×1