i have this entire code but nothing showes up. what is problem?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Noise : MonoBehaviour
{
    public static int xlenght = 250;
    public static int ylenght = 250;
    [SerializeField] float[] Frequencies;
    [SerializeField] float[] Amplitudes;
    float[,] generatednoise = new float[xlenght + 1, ylenght + 1];
    Texture2D texture;
    [SerializeField] Material mat;
    [SerializeField] float scale;
    public float xOffset;
    public float yOffset;
    [SerializeField] terrainrype[] terrainrypearray;
    Mesh mesh;
    Vector3[] vertecies = new Vector3[(xlenght + 1) * (ylenght + 1)];
    [SerializeField] MeshCollider terraincollider;
    private void Start()
    {
        mesh = new Mesh();
        GetComponent<MeshFilter>().mesh = mesh;
        calculatenoise();
        updatemesh();
        mat.mainTexture = generatetexture(texture);
    }
    private void Update()
    {

    }

    Texture2D generatetexture(Texture2D texture)
    {
        texture = new Texture2D(xlenght, ylenght);
        for (int x = 0; x <= xlenght; x++)
        {
            for (int y = 0; y <= ylenght; y++)
            {
                for (int i = 0; i < Amplitudes.Length; i++)
                {
                    texture.SetPixel(x, y, calculatecolor(x, y));
                }

            }
        }

        texture.Apply();
        return texture;

    }

    void calculatenoise()
    {

        for (int x = 0, e = 0; x < xlenght + 1; x++)
        {
            for (int y = 0; y < ylenght + 1; y++)
            {
                for (int i = 0; i < Amplitudes.Length; i++)
                {
                    generatednoise[x, y] += Amplitudes _* Mathf.PerlinNoise(_

Frequencies * x / xlenght * scale + xOffset, Frequencies * y / ylenght * scale + yOffset);
}
vertecies[e] = new Vector3(x, generatednoise[x,y], y);
e++;

}
}

}

int[] trianglesgenerate()
{
int[] triangles = new int[xlenght * ylenght * 6];
int tris = 0;
int verts = 0;
for (int y = 0; y < ylenght; y++)
{
for (int x = 0; x < xlenght; x++)
{
triangles[tris] = verts + 0;
triangles[tris + 1] = verts + xlenght + 1;
triangles[tris + 2] = verts + xlenght + 1;
triangles[tris + 3] = verts + 1;
triangles[tris + 4] = verts + 1;
triangles[tris + 5] = verts + xlenght + 2;
tris += 6;
verts++;
}
}

return triangles;
}
Color calculatecolor(int x, int y)
{
float sample = 0;
Color color = Color.white;
sample = generatednoise[x, y];

for (int a = 0; a < terrainrypearray.Length; a++)
{
if (sample <= terrainrypearray[a].depth)
{

color = terrainrypearray[a].color;
break;
}

}

return color;
}

[System.Serializable] public struct terrainrype
{
public string name;
public float depth;
public Color color;
}
void updatemesh()
{
mesh.Clear();
mesh.vertices = vertecies;
mesh.triangles = trianglesgenerate();
mesh.RecalculateNormals();
mesh.RecalculateBounds();

}

}

Attach your Visual Studio instance to Unity, choose some lines of the code to inspect, and press F9 while on them to add a breakpoint. When you run Unity, your Visual Studio debugger should halt wherever you put your breakpoints if your code is getting executed. From there, you can inspect the different variables you’ve calculated to see what’s wrong.

If your breakpoint isn’t getting hit, you need to attach your component to a game object in the scene that’s executing.

your triangle code generation is iffy

 triangles[triIndex] = y * size + x;
    triangles[triIndex + 1] = (y + 1) * size + x;
    triangles[triIndex + 2] = y * size + (x + 1);
    triangles[triIndex + 3] = y * size + (x + 1);
    triangles[triIndex + 4] = (y + 1) * size + x;
    triangles[triIndex + 5] = (y + 1) * size + (x + 1);
    triIndex += 6;

this is generally how it is done, there is no multiplication in your code, only addition, i think your triangles are not properly being generated.

Also, it would be very useful for you to use proper naming technique too for your variables and function names.
i have to go to work now so i cant look any more, if it hasn’t been answered by the time i get back, ill look deeper for ya, good luck! :smiley: