Object spawning script Unity
public Transform[] obstaclePrefab;


That's wrong. Prefabs are of type GameObject, not Transform.



private float minSpawnTime;
private float maxSpawnTime;


Why did you make these private? They should have been public with default values - just as all the others.

private float boxPositionY;
private float boxPositionX;
// Distances
private float playerDistance;
private float boxDistance;
private float ySpread;


These shouldn't even been private, but local to the Update() method, as their values are never reused.



// Select box color
int boxColor = Random.Range(0, 4);


This is very likely to break. Better read the array length instead of hard coding it:

// Select box color
int boxColor = Random.Range(0, obstaclePrefab.Length - 1);


Or just get rid of boxColor all together:

// Select box
GameObject box = obstaclePrefab[Random.Range(0, obstaclePrefab.Length - 1)];




// Count the random spawn time
timeCounter += Time.deltaTime;
if(timeCounter &gt;= spawnTime) 
{
    // Make new random spawn time
    spawnTime = Random.Range (minSpawnTime, maxSpawnTime);
    timeCounter = 0;
}


That's one way to do it. The cleaner method would have been to handle this in a Coroutine and then use WaitForSeconds. Right now, your code runs every single frame, without actually doing anything useful.



Debug.Log ("Spawn Time: " + spawnTime + " spawnCount: " + timeCounter);


Be careful when you log. Logging when something spawns? OK. But spamming a log entry every single frame? Waste of resources.



boxPositionX = (boxPositionX-1)*2.0f;


What is this line supposed to do? That should have been directly computed into minXDistance and maxXDistance, so this line is obsolete.



If this is actually supposed to be C#, the whole script you posted should actually have wrapped in a regular C# class:

using UnityEngine;
using System.Collections;

public class ScriptName : MonoBehaviour {
    // &lt;---- Your stuff goes here
}


Did you just omit this when posting your code here, or did you actually write your scripts without it?