我正在尝试使用柏林噪声和统一的行进立方体来创建程序地形生成器。它一直有效,直到我从创建高度图切换到将其制作成 3d 数组。然后,每当我单击播放时,Unity都会打开一个对话框,其中写入了Application.EnterPlayMode,该对话框不会消失并且永远不会进入播放模式。当发生这种情况时,一切都会停止响应,阻止它的唯一方法就是在任务管理器中杀死它。
有问题的脚本如下:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Noise : MonoBehaviour
{
//Determines whether to show debug values
public bool debug = false;
//Determines flatness of the terrain
public float noiseScale = 0.5f;
//Type of perlin noise to use
public enum PerlinNoise {
twoD,
threeD
};
public PerlinNoise perlinNoiseDimension = PerlinNoise.twoD;
//To return noise data after all calculations
public float[,,] getTerrainData(int x, int y, int z)
{
float[,,] terrainData = new float[x, y, z];
if(perlinNoiseDimension == …Run Code Online (Sandbox Code Playgroud)