在学习教程时,我在此脚本上遇到此错误
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour
{
public GameObject prefab;
// Instantiate the Prefab somewhere between -10.0 and 10.0 on the x-z plane
void Start()
{
Vector3 position = new Vector3(Random.Range(-10.0f, 10.0f), 0, Random.Range(-10.0f, 10.0f))
Instantiate(prefab, position, Quaternion.identity)
}
}
答案 0 :(得分:2)
声明必须以;
Statements (C# Programming Guide)
一条语句可以由一行以结尾的代码组成 分号,或一个块中的一系列单行语句
Vector3 position = new Vector3(...); <== note the semicolon
Instantiate(...); <== note the semicolon
错误告诉你的是什么
答案 1 :(得分:0)
这是脚本的外观。
<DIV>
答案 2 :(得分:0)
请记住输入“;”在这样的行末
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour
{
public GameObject prefab;
// Instantiate the Prefab somewhere between -10.0 and 10.0 on the x-z plane
void Start()
{
Vector3 position = new Vector3(Random.Range(-10.0f, 10.0f), 0, Random.Range(-10.0f, 10.0f));
Instantiate(prefab, position, Quaternion.identity);
}
}