Okay, I have seen many answers for this question, but none seem to work. I need a way to randomly select a level between two levels, when a button is touched. I am not very good at making scripts. And iv’e tried many scripts, but none work at all. Does anyone know anything about this?
You can load scenes by their number or name.
int[] numbers = {0,1}; //possible random numbers
string[] scenenames = {"scene1", scene2}; //scene names in order of numbers //0 = scene1, 1 = scene2
SceneManager.LoadScene( scenenames[Random.Range(0,numbers.lenght)] ); //place this inside void
Here is the current script I have: using UnityEngine;
using System.Collections;
public class RandomLevelHe2 : MonoBehaviour {
public Object He2;
public Object TapTest;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {if ((Input.touchCount == 1) &&
(Input.GetTouch(1).phase == TouchPhase.Began) ){
Application.LoadLevel ("He2");
Application.LoadLevel ("TapTest");
}
}
}