Dan*_*wis -3 c# monodevelop unity-game-engine
我一直关注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++) {
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);
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
该错误在第一行公开.
| 归档时间: |
|
| 查看次数: |
1404 次 |
| 最近记录: |