原代码如下:
if (Input.GetKeyDown(KeyCode.Space))
GameObject bullet = Instantiate(bulletPrefab, mount.position, transform.rotation) as GameObject;
报错:嵌入的语句不能是声明或标记语句
改为
if (Input.GetKeyDown(KeyCode.Space))
{
GameObject bullet = Instantiate(bulletPrefab, mount.position, transform.rotation) as GameObject;
}
即可