我有一个四边形对象,其中有一个png图形作为子对象。
这个区域是点击区域。
我给这个对象附加了一个脚本,里面有代码。
// Update is called once per frame
void FixedUpdate () {
bool tapped = Input.GetButton("Fire1");
if (tapped){
Debug.Log ("diram");
}
}
Up]
. Those methods return true respectively in the first frame the button is pressed or release.
Consider also read input events inside当你按住按钮时返回true。你应该使用
public float delay; //change this in the Inspector
public bool canshoot = true;
private void Start()
{
bool input = Input.GetButton("Fire 1");
if(input && canshoot){
canshoot=false;
Shoot() // your shooting function)
StartCoroutine(Reset(delay));
}
}
IEnumerator Reset(float time){
yield return new WaitForSecondsRealTime(time);
canshoot = true;
}
Input.GetButton[Down