I need to set up a single scene where one of five meshes appears when the scene starts. A variable is storing a number between 1 and 5 in a scene manager script before the scene loads, and the names of the meshes are numbered 1 through 5. How can I configure my scene so the mesh that corresponds with the variable is instantiated into the scene?
Not necessarily looking for specific scripting advice, but more general advice about how to set this up.
var meshes : GameObject[] = new GameObject[5]; //Assign your prefabs in inspector
function Start () {
Instantiate(meshes[Random.Range(0,5)], Vector3.zero, Quaternion.identity);
}
Instead of Random.Range() you would call SceneManager.meshNumber. Setting that number could be like this,