首页 > 解决方案 > 脚本错误:';' 预期的。统一错误

问题描述

在遵循教程时,我在此脚本上遇到此错误

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#unity3d

解决方案


语句需要以;

语句(C# 编程指南)

语句可以由以分号结尾的单行代码组成,也可以由块中的一系列单行语句组成

Vector3 position = new Vector3(...); <== note the semicolon
Instantiate(...); <== note the semicolon

这是错误告诉你的


推荐阅读