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)