cant see mesh

I am generating a mesh with custom amount of sub-divisions, known as side length in the code, when I click on the mesh filter I see that the amount of vertices, triangles and uvs, but no mesh, not even in wireframe, here is the code if you need to see it, it is executable in edit mode

using System.Collections.Generic;
using UnityEngine;

[ExecuteInEditMode]
public class TerrainObj : MonoBehaviour
{
    [SerializeField] private List<int> Triangles;
    private Mesh mesh;
    [Range(3, 9999)]
    [SerializeField] private int sideLength;
    [SerializeField] private bool generateNewMesh;
    [SerializeField] private List<Vector3> Vertices;
    [SerializeField] private List<Vector2> UVs;

    private void Awake()
    {
        sideLength = 2;
        GetComponent<MeshFilter>().mesh = new Mesh();
        mesh = GetComponent<MeshFilter>().sharedMesh;
    }

    private void Update()
    {
        if (generateNewMesh == true) Generate();
    }

    private void Generate()
    {
        generateNewMesh = false;
        Triangles = new List<int>();
        Vertices = new List<Vector3>();
        UVs = new List<Vector2>();

        for (int x = 0; x < sideLength; x++)
        {
            for (int z = 0; z < sideLength; z++)
            {
                Vertices.Add(new Vector3(x, 0, z));

                Triangles.Add(x + z);
                Triangles.Add(x + (z + 1));
                Triangles.Add((x + 1) + z);

                Triangles.Add(x + (z + 1));
                Triangles.Add((x + 1) + z);
                Triangles.Add((x + 1) + (z + 1));
                Debug.Log("E");
            }
        }

        foreach(Vector3 vec in Vertices)
        {
            UVs.Add(new Vector2(vec.x, vec.z));
        }

        UpdateMesh();
    }

    private void UpdateMesh()
    {
        mesh.Clear();
        mesh.SetVertices(Vertices);
        mesh.SetTriangles(Triangles, 0);
        mesh.SetUVs(0, UVs);
    }
}

It seems like you’re on the right track, but there could be some things going wrong that I noticed. One possibility is that the mesh is not being properly assigned to the MeshFilter component. In your code, you’re creating a new Mesh object in the Awake() method, but then in the UpdateMesh() method you’re updating the mesh’s vertices, triangles, and UVs. This might be clearing the mesh and making it disappear. Another possibility is that the camera might not be in the right position to see the mesh. Have you tried moving the camera around to see if the mesh is visible from a different angle? If neither of these things work, it might be helpful to add some debug statements to your code to see if there are any errors or unexpected behavior happening.