Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# C语言中的二维数组问题# 使用系统集合; 使用System.Collections.Generic; 使用UnityEngine; 公共静电级噪声 { 公共静态浮点[,]GenerateNoiseMap(int-mapWidth、int-mapHeight、浮点比例) { float[,]noiseMap=新的float[mapWidth,mapHeight]; 如果(比例_C#_Arrays_Unity3d_Multidimensional Array - Fatal编程技术网

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++)