简体   繁体   English

Unity3D滑动控件以递增计数器(C#)

[英]Unity3D swipe controls to increment counter (C#)

I've looked around for various swiping-related answers, and could not find anything that suited me directly. 我到处寻找各种与刷卡相关的答案,但找不到直接适合我的内容。

The idea is to swipe left to increment an integer variable, and left to decrement it. 想法是向左滑动以增大整数变量,向左滑动以减小整数变量。 I have it working for buttons, and would simply like to convert it for a touch input. 我有它用于按钮的功能,只是想将其转换为触摸输入。

The current script is as follows: 当前脚本如下:

private void Buttons(){
        if (GUI.Button (new Rect (1080,80, 40, 220), "Next")) {
        screenNumber ++;
    }
        if (GUI.Button (new Rect (160,80, 40, 220), "Back")) {
        screenNumber --;
    }       
}

*screenNumber is the name of the int variable. * screenNumber是int变量的名称。

I am developing for Android, if that is important for this functionality. 我正在为Android开发,如果这对于此功能很重要。

Thanks in advance! 提前致谢!

I've been using FingerGestures for both mouse and touch controls. 我一直在将FingerGestures用于鼠标和触摸控件。 I highly recommend it, especially for painless Touch/Mobile development. 我强烈建议您使用它,尤其是对于轻松的触摸/移动开发而言。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM