我在遵循教程时在此脚本上出现此错误
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)
}
}
语句需要以;
结尾语句(C# 编程指南(
语句可以由以 分号,或块中的一系列单行语句
Vector3 position = new Vector3(...); <== note the semicolon
Instantiate(...); <== note the semicolon
这就是错误告诉您的内容
记得把";"放在这样的行尾
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);
}
}
这就是你的脚本应该是什么样子的。
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);
}
}