Help with perlin noise terran generation script

So, I’ve stuck on this issue for a couple of days and to save what little of my hair I have left, I’ll ask you good people for some help.

I have some code that creates some terrain in a 25x25 grid of cubes based of perlin noise. it also creates a flat bottom area of the same size. What I want to do is fill the area between the top terrain and the bottom.

Here’s the code for the terrain Gen.

void Start()
        // Creation of terrain
        for (var X = 0; X < Size; X++)
            for (var Z = 0; Z < Size; Z++)
                    var TheLandCreator = Instantiate(ThePlatform, new Vector3(X, 0, Z), Quaternion.identity) as GameObject;
                    TheLandCreator.transform.parent = transform;

                    Instantiate(Bottom, new Vector3(X, -5, Z), Quaternion.identity);
                    Red = 0.14f;
                    Green = -0.22f;
                    Blue = -0.51f;
                    Scale = Random.Range(6f, 14f);
                    ScaleModifier = Random.Range(-5f, 14f);

Here’s an image of what this creates.

I’ve Tried this in a variety of ways. The last way I tried was attaching a script to the terrain cube which instantiated more cubes down to the bottom, until it collided with the bottom layer. Unfortunately this script crashes Unity? Here’s the script… I’m only showing it to see if I was on the right track or whether I’m over thinking the whole thing.

using UnityEngine;
using System.Collections;

public class TerrainFill : MonoBehaviour {
    public Transform Cube;
    public GameObject CubeFill;
    public bool HitBottom = false;

    // I want to spawn a cube under the terrain until it hits the bottom layer.

    void Start ()

    void StartSpawningTheFillPlease()
        for (var Y = 0; HitBottom == false; Y++)
            Instantiate(CubeFill, new Vector3(0, Y-1, 0), Quaternion.identity);            

    void OnTriggerEnter(Collider other)
        HitBottom = true;

Any help anyone can give is greatly appreciated. Many thanks

The reason why it crashes is because if you fill the area between the bottom and the top you create too much objects, probably more than unity can handle. I know what you are trying to achieve but this is very inefficient way to make your perlin terrain. The way how you SHOULD do it is by making the whole area with only one object which is called a chunk. However this requires at least a basic knowledge of procedural mesh building. Check youtube for some tutorials there are plenty of them… - YouTube