C# 无法使用GUI.Button移动播放机
我正在创建一个简单的游戏,现在我要移动我的玩家。我想用手机上的四个触摸按钮移动我的播放器。我正在使用GuitTexture按钮并使用下面的代码。但是,我遇到了以下错误: 与UnityEngine.GUI.ButtonUnityEngine.Rect的最佳重载方法匹配的字符串具有一些无效参数 如何修复它 代码C# 无法使用GUI.Button移动播放机,c#,unity3d,unityscript,C#,Unity3d,Unityscript,我正在创建一个简单的游戏,现在我要移动我的玩家。我想用手机上的四个触摸按钮移动我的播放器。我正在使用GuitTexture按钮并使用下面的代码。但是,我遇到了以下错误: 与UnityEngine.GUI.ButtonUnityEngine.Rect的最佳重载方法匹配的字符串具有一些无效参数 如何修复它 代码 若你们想在按钮上显示文字,那个么只需在左、下、上、右引号中加上。如果您想要带有图像的按钮,请将GuitTexture类型更改为纹理或纹理2D,如此处所述-左、右、上、下不是字符串,它们被声明
若你们想在按钮上显示文字,那个么只需在左、下、上、右引号中加上。如果您想要带有图像的按钮,请将GuitTexture类型更改为纹理或纹理2D,如此处所述-左、右、上、下不是字符串,它们被声明为GuitTexture如何解决此问题?请更正我的密码好吗?
public class Player : MonoBehaviour {
public float movement;
public Vector3 input;
private float maxSpeed=15f;
private Vector3 spawn;
public GameObject deathparticales;
public GUITexture Left;
public GUITexture Right;
public GUITexture Up;
public GUITexture Down;
private bool moveRight, moveLeft, moveUp, moveDown;
// Use this for initialization
void Start () {
spawn = transform.position;
}
// Update is called once per frame
void Update () {
if (GUI.Button(Rect (50,50,50,50), Left))
{
Vector3 position = this.transform.position;
position.x--;
this.transform.position = position;
}
if (GUI.Button(Rect (100,50,50,50), Right))
{
Vector3 position = this.transform.position;
position.x++;
this.transform.position = position;
}
if (GUI.Button(Rect (75,100,50,50), Up))
{
Vector3 position = this.transform.position;
position.y++;
this.transform.position = position;
}
if (GUI.Button(Rect (25,100,50,50), Down))
{
Vector3 position = this.transform.position;
position.y--;
this.transform.position = position;
}
if (transform.position.y < -1) {
Die ();
}
}
void OnCollisionEnter(Collision death)
{
if(death.transform.tag == "Enemycollision")
{
Die();
}
}
void OnTriggerEnter(Collider target)
{
if (target.transform.tag == "Target") {
Gamemanager.completelevel();
}
}
void Die()
{
Instantiate(deathparticales,transform.position,Quaternion.Euler(270,0,0));
transform.position=spawn;
}
}