Unity:错误 CS1041 on line 5: Identifier expected: 'public' is a keyword?

Unity: Error CS1041 on line 5: Identifier expected: 'public' is a keyword?

我一直在关注 Unity3D Procedural Cave Generation,但我很早就在 MapGeneration.cs 中发现了一个错误。 Unity 表示在第 1 行第 1 个词中出现错误: 预期标识符:'public' 是关键字 。我看不出我的代码和教程的代码有什么不同。这是教程视频的 link:[\Tutorial video 1] 这是我的代码:

using UnityEngine;
using System.Collections;
using System

public class MapGeneration : MonoBehaviour {

    public int width;
    public int height;

    public string seed;
    public bool useRandomSeed;

    [Range(0,100)]
    public int randomFillPercent;

    int[,] map;

    void Start() {
        GenerateMap();
    }

    void GenerateMap() {
        map = new int[width,height];
    }

    void RandomFillMap() {
        if (useRandomSeed) {
            seed = Time.time.ToString();
        }

        System.Random psuedoRandom = new System.Random(seed.GetHashCode());

        for (int x = 0; x < width; x++) {
            for (int y = 0; y < height; y ++) {
                map[x,y] = (psuedoRandom.Next(0,100) < randomFillPercent)? 1: 0;
            }
        }
    }

    void OnDrawGizmos() {
        if (map != null) {
            for (int x = 0; x < width; x++) {
                for (int y = 0; y < height; y ++) {
                    Gizmos.color = (map[x,y] == 1)? Color.black: Color.white;
                    Vector3 position = new Vector3(-width/2 + x + .5f,0,-height/2 + y + .5f);
                    Gizmos.DrawCube(position,Vector3.one);
                }
            }
        }
    }
}

第一行的错误是public

您在 using System 之后没有 ;(这可能也是一个不完整的导入)。