Procedural level generation for a 3D side-scroller

So I was planning on working on a 3D side-scroller game with a character that automatically starts moving at the beginning of the stage. However, I decided to extend the game's playability through procedural level generation which I want to do in 3D graphics (assuming that it isn't to much different from 2D in theory since i'm only using 2 axes).

So, I figure that the best way to go at it by making modular level components (level blocks) that are like, 30 x 30 and spawning them into a series to create a randomly generated level. My problem is I'm not sure how to spawn them in a somewhat controllable fashion to where, say, a slope piece should be spawned after every [x] blocks, and that the next piece should be [y -=30] (assuming 2 axes are being used) lower than that previous piece.

I also would like to randomly spawn objects and obstructions aligned on top of those pieces. How should I go forth creating a script that can pull of the spawning and alignment of my level blocks? And since I plan to have this on a mobile platform, would it be efficient enough to create the level from the beginning or should a create a set amount of blocks at a time?

Lastly, I want to have a block counter that assigns a number to each instanced block. This way, I can track the amount of blocks spawned, identify each spawned block, and set a condition after a certain amount of blocks have been spawned.

Technically speaking, the solution i can think of for alignment, is that in each modular component (prefabs) make an empty gameobject as a child and name it "anchor" then in the script where you instantiate new blocks, store the last instantiated gameobject into a variable and before the next block being instantiated look for the last block's "anchor" and make it the position for the new block. This will gives you ability to put the anchor wherever you want and make sure that everything matches seamlessly. And yes, as you also mentioned, I think it's efficient to consider a sight range for your character to limit the amount of process needed.

I've created a sample scene for you to download. I didn't know how to explain here:

http://dl.dropbox.com/u/4659539/ProceduralLevel.unitypackage

When you play use (A-D or Left-right arrow)

Here is the code for everyone:

var blockPrefabs:GameObject[] = new GameObject[2]; //Lets say you have only 2 different blocks.
var lastBlock:GameObject; // Store the last/current block. Remember that the first block shoul be in scene and assigned to this variable.

private var nextStop:Vector3;

function Start(){
    nextStop = transform.position + Vector3.forward *0.1;
}

function Update () {
    RollCamera();
    var currPos:Vector3 =transform.position;
    print(Vector3.Distance(nextStop,currPos));
    if(Vector3.Distance(nextStop,currPos)>5){
        CreateNewBlock();
        nextStop = transform.position + Vector3.forward *0.1;
    }
}

function CreateNewBlock(){
    var insPos:Vector3 = lastBlock.transform.Find("Front_Anchore").transform.position;
    var newBlock:GameObject = Instantiate(blockPrefabs[Mathf.Floor(Random.Range(0,2))],insPos, lastBlock.transform.rotation);
    lastBlock = newBlock;
}

function RollCamera(){
    transform.Translate(Input.GetAxis("Horizontal") * Vector3.right * 0.2);
}

For the random spawn points you could calculate them in 2D and use a raycast to find the height or place transform nodes inside the block tiles and select a random number at runtime.

The "anchor" idea by Kourosh is great.

You could also define a “dictionary” where all possible neighbors and transforms for a given block are listed.