Raycast doesn't work for procedural terrain

You probably just have a bug.

Fabricating a Mesh and putting it on a MeshCollider is absolutely sense-able by Raycast immediately.

Source: I do it all the time, such as with my spawn point lifter:

Proof in immediately-runnable code:

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

// @kurtdekker - you CAN hit geometry you just created.
// to see, drop this on a blank GameObject and press PLAY

public class MakeAndHit : MonoBehaviour
{
    void Start ()
    {
        GameObject tri = new GameObject();

        tri.name = "Target!";

        Mesh mesh = new Mesh();

        mesh.vertices = new Vector3[] {
            new Vector3( -1, -1, 1),
            new Vector3( -1, +1, 1),
            new Vector3( +2, +0, 1),
        };
        mesh.triangles = new int[] {
            0, 1, 2,
        };

        MeshCollider mc = tri.AddComponent<MeshCollider>();
        mc.sharedMesh = mesh;

        Ray ray = new Ray( origin: Vector3.zero, direction: Vector3.forward);

        RaycastHit hit;
        if (Physics.Raycast( ray, out hit, Mathf.Infinity))
        {
            Debug.Log( "Hit " + hit.collider.name);
        }
        else
        {
            Debug.Log( "Missed.");
        }
    }
}

9635813--1369454--Screen Shot 2024-02-10 at 7.22.14 AM.png

More Unity meshy goodness and other procgen stuff here: MakeGeo is presently hosted at these locations:

https://bitbucket.org/kurtdekker/makegeo