我一直收到array.Select的错误

时间:2018-04-15 03:01:12

标签: javascript unity3d

所以我正在创造这个行星世界的一代系统并且遇到了错误。

它一直在说...。当我删除Range的int count部分时,它给了我另一个错误。我从在线发现的javascript应用程序中移植了这个。任何帮助表示赞赏!

No overload for method 'Select' takes 5 arguments

如果需要原始的javascript代码:

using UnityEngine;
using System.Collections;
using System;
using System.Linq;

public class WorldGeneration: MonoBehaviour {
    float tileX;
    float tileY;
    void Generate() {
        float offset = .01f;

        int resolution = 360;
        int radius = 100;
        int noiseHeight = 50;
        int circleX = 1000;
        int circleY = 1000;
        var TWO_PI = Math.PI*2;

        for(int i=0; i<resolution; i++) {

            float angle = Enumerable.Range(1, 1000).Select(i,0,resolution,0,TWO_PI);
            float circleOffX = (float)Math.Cos(angle+offset) * (radius+Mathf.PerlinNoise(i*0.1f,offset)*noiseHeight);
            float circleOffY = (float)Math.Sin(angle+offset) * (radius+Mathf.PerlinNoise(i*0.1f,offset)*noiseHeight);

            tileX = circleX + circleOffX;
            tileY = circleY + circleOffY;
        }

        var width = 0.16f;
        var height = 0.16f;

        var manager = GetComponent<TileManager>();
        var obj = manager.Generate(1);
        obj.transform.position = new Vector2(tileX * width, tileY *  height);
    }
}

1 个答案:

答案 0 :(得分:3)

错误告诉您没有Select函数需要5个参数。

因此,Select(i,0,resolution,0,TWO_PI)在代码的以下行中无效,因为它有5个参数(i0resolution0和{ {1}})

TWO_PI

查看float angle = Enumerable.Range(1, 1000).Select(i,0,resolution,0,TWO_PI); 的{​​{3}}并查找可用的参数,并更正Select的来电。