C# C语言中的二维数组问题# 使用系统集合; 使用System.Collections.Generic; 使用UnityEngine; 公共静电级噪声 { 公共静态浮点[,]GenerateNoiseMap(int-mapWidth、int-mapHeight、浮点比例) { float[,]noiseMap=新的float[mapWidth,mapHeight]; 如果(比例
你的问题在这里:C# C语言中的二维数组问题# 使用系统集合; 使用System.Collections.Generic; 使用UnityEngine; 公共静电级噪声 { 公共静态浮点[,]GenerateNoiseMap(int-mapWidth、int-mapHeight、浮点比例) { float[,]noiseMap=新的float[mapWidth,mapHeight]; 如果(比例,c#,arrays,unity3d,multidimensional-array,C#,Arrays,Unity3d,Multidimensional Array,你的问题在这里: using System.Collections; using System.Collections.Generic; using UnityEngine; public static class noise { public static float[,] GenerateNoiseMap(int mapWidth, int mapHeight, float scale) { float[,] noiseMap = new float[ma
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class noise
{
public static float[,] GenerateNoiseMap(int mapWidth, int mapHeight, float scale)
{
float[,] noiseMap = new float[mapWidth, mapHeight];
if (scale <= 0)
{
scale = 0.0001f;
}
for(int y = 0; y<mapHeight; y++)
{
for (int x = 0; y < mapWidth; x++)
{
float sampleX = x/(mapWidth * scale);
float sampleY = y/(mapHeight * scale);
float perlinValue = Mathf.PerlinNoise(sampleX, sampleY);
noiseMap[x, y] = perlinValue;
Debug.Log(noiseMap.GetLength(0));
Debug.Log(noiseMap.GetLength(1));
}
}
return noiseMap;
}
}
for(int x=0;y
应该是:
for (int x = 0; y < mapWidth; x++)
for(int x=0;x
for(int x=0;yfor (int x = 0; x < mapWidth; x++)