// Start is called before the first frame update
    public void generateMap()
    {
        texture              = new Texture2D(width, height, TextureFormat.ARGB32, false);
        noiseMap             = GenerateNoiseMap.generateNoiseMap(height, width, scale, offset);
        transform.localScale = new Vector3(width, 1, height);
        for (int y = 0; y < height; y++)
        {
            for (int x = 0; x < width; x++)
            {
                if (!color)
                {
                    texture.SetPixel(y, x, Color.Lerp(Color.black, Color.white, noiseMap[y, x]));
                }
                else
                {
                    texture.SetPixel(y, x, getNoiseValueColor(noiseMap[y, x]));
                }
            }
        }

        drawMesh();

        texture.Apply();
        GetComponent <Renderer>().sharedMaterial.SetTexture("_MainTex", texture);
    }
示例#2
0
    public override void OnInspectorGUI()
    {
        GenerateNoiseMap mapGen = (GenerateNoiseMap)target;

        if (DrawDefaultInspector())
        {
            if (mapGen.autoUpdate)
            {
                mapGen.GenerateMap();
            }
        }

        if (GUILayout.Button("Init"))
        {
            mapGen.GenerateMap();
        }
    }