我一直关注Unity3D 程序洞穴生成,但我在MapGeneration.cs中很早就发现了一个错误.Unity说第1行第1行有一个错误:标识符预期:'public'是一个关键字.我看不出我的代码和教程代码有什么不同.这是教程视频的链接:[ \ 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++) { …Run Code Online (Sandbox Code Playgroud)