12

私は以下のコードを持っていて、PerlinNoise(x,z) を丸めようとしているので、Yscale に等しくして丸めようとしました。問題は、その行に対して「名前 `Math' は現在のコンテキストに存在しません」というエラーが表示されることです。何か案は?

using UnityEngine;
using System.Collections;

public class voxelcreate : MonoBehaviour {
private int origin = 0;
private Vector3 ChunkSize = new Vector3 (32,6,32);
private float Height = 10.0f;
private float NoiseSize = 10.0f;
private float Yscale=0;
private GameObject root;
public float PerlinNoise(float x, float y)
{
    float noise = Mathf.PerlinNoise( x / NoiseSize, y / NoiseSize );
    return noise * Height;

}

// Use this for initialization
void Start () {
    for(int x = 0; x < 33; x++){
        bool isMultiple = x % ChunkSize.x == 0;
        if(isMultiple == true){
        origin = x;
Chunk();}
    }
}

// Update is called once per frame

void Chunk (){
    int ranNumber = Random.Range(8, 80);
    int ranNumber2 = Random.Range(8, 20);
    Height = ranNumber2;
    NoiseSize = ranNumber;
    for(int x = 0; x < ChunkSize.x; x++)
    {
for(int y = 0; y < ChunkSize.y; y++)
{
    for(int z = 0; z < ChunkSize.z; z++)
    {
GameObject box = GameObject.CreatePrimitive(PrimitiveType.Cube);
                int Yscale = (int)Math.Round((PerlinNoise( x, z)), 0);
           box.transform.position = new Vector3( origin+x , y+Yscale, z);
}}}}}
4

3 に答える 3

27

追加

using System;

ファイルの上部にあります。

またはSystem.Mathの代わりに使用しMathます。

于 2013-11-01T22:46:11.593 に答える
1

ASP.NET Core では、最初に System.Runtime.Extension パッケージを取得する必要があります。おそらく、Visual Studio の NuGet パッケージ マネージャーまたはコマンド ラインを使用します。

パッケージの詳細については、こちらをご覧ください

最後に、次を与える必要があります。

using System

そして、このクラスのメソッドを使用できます:

            using System;
            namespace Demo.Helpers
            {
                public class MathDemo
                {
                    public int GetAbsoluteValue()
                    {
                        var negativeValue = -123;
                        return Math.Abs(negativeValue);
                    }
                }
            }
于 2017-01-02T10:43:58.640 に答える