Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ';输入';不包含';触摸屏';_C#_Android_Unity3d - Fatal编程技术网

C# ';输入';不包含';触摸屏';

C# ';输入';不包含';触摸屏';,c#,android,unity3d,C#,Android,Unity3d,有人知道这个代码有什么问题吗?这是一个统一的基本游戏。错误表示“输入”不包含“触摸”的定义。顺便说一句,我没有任何名为输入的文件 using System.Collections; using System.Collections.Generic; using UnityEngine; public class Move : MonoBehaviour { private Touch touch; private float speedModifier; // Start is call

有人知道这个代码有什么问题吗?这是一个统一的基本游戏。错误表示“输入”不包含“触摸”的定义。顺便说一句,我没有任何名为输入的文件

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Move : MonoBehaviour
{   
private Touch touch;
private float speedModifier;
// Start is called before the first frame update
void Start()
{
    speedModifier = 0.01f;
}

// Update is called once per frame
void Update()
{
    if (Input.touch > 0)
    {
        touch = Input.GetTouch(0);

        if (touch.phase == TouchPhase.Moved)
        {
        transform.position = new Vector3(
            transform.position.x + touch.deltaPosition.x * speedModifier,
            transform.position.y,
            transform.position.z + touch.deltaPosition.y * speedModifier);
        }
    }
}

}您需要更改您的

if (Input.touch > 0)


正如错误消息所说,没有关于
Input.touch
的定义,但是您希望使用if语句来确保
Input.GetTouch(0)
不会返回null

您在代码中引用的
Input
的类型是什么?编译器告诉您该对象没有触摸键property@RufusL很可能;)…=>@好吧,它不。。。请查看API并使用其中一个现有字段/属性^^^也请使用正确的标记
unityscript
是早期Unity版本中使用的一种类似JavaScript风格的自定义语言,现在已经被长期弃用了!谢谢你的帮助,不客气。如果它回答了您的问题,而您没有任何其他问题,请接受答案
if (Input.touchCount > 0)