将统一输入更改为跨平台输入

时间:2019-01-05 16:16:43

标签: c# unity3d cross-platform

这是我通过在线教程编码的代码,它是正常的刷卡输入,但我想将其更改为跨平台输入。我不知道如何更改它,希望你们能帮助我

if (Input.touchCount == 1)
{
    if (isSwipping)
    {
        Vector2 diff = Input.GetTouch(0).position - startingTouch;
        diff = new Vector2(diff.x / Screen.width, diff.y / 
        Screen.width);

        if (diff.magnitude > 0.01f)
        {
            if (Mathf.Abs(diff.y) > Mathf.Abs(diff.x))
            {
                if (diff.y < 0)
                {
                    Slide();
                }
                else
                {
                    Jump();
                }
            }
            else
            {
                if (diff.x < 0)
                {
                    ChangeLane(-1);
                }
                else
                {
                    ChangeLane(1);
                }
            }

            isSwipping = false;
        }
    }

    if (Input.GetTouch(0).phase == TouchPhase.Began)
    {
        startingTouch = Input.GetTouch(0).position;
        isSwipping = true;
    }
    else if (Input.GetTouch(0).phase == TouchPhase.Ended)
    {
        isSwipping = false;
    }
}

0 个答案:

没有答案