Above are two files of the same game: one in editor and one is OSX Build.
There problem seems from this
public sealed class Cubes : MonoBehaviour
{
private const string CUBE_NAME = "Cube";
public List<Cube> cubeList;
public void Load (List<DataCube.Cube> cubeTypes)
{
//10 cubes
for (int i = 0; i < cubeList.Count; i++) {
int random = UnityEngine.Random.Range (0, cubeTypes.Count);
DataCube.Cube cube = cubeTypes [random];
cubeList [i].Load (transform, cube.color);
}
}
}
public sealed class Cube : MonoBehaviour
{
public void Load (Transform parent, Color color)
{
transform.parent = parent;
bool isOverlay = false;
do {
float x = UnityEngine.Random.Range (0f, 1f);
float y = UnityEngine.Random.Range (0f, 1f);
transform.position = Camera.main.ViewportToWorldPoint (new Vector3 (x, y, 10f));
isOverlay = Physics.OverlapSphere (transform.position, 1f).Length > 0 ? true : false;
} while(isOverlay);
renderer.enabled = true;
renderer.material.color = color;
gameObject.SetActive (true);
}
}
Is there anything wrong with this code? If it works in the Editor, I can’t see any reason why it should work in a build…

