load a random scene / level in unity
load a random scene / level in unity How to load random scene in unity
in this tutorial i will give you to methode to apply the random loading.
Metode 1 :
1 - After creatings the scenes , in your scripts for loading a scene add the library of Scene Management.
using UnityEngine.SceneManagement;
2 - hen add this variable:
public int levelGenerate;
3 - Now copy and past this fonction :
public void LevelToLoad()
{
levelGenerate = Random.Range(2, 3);
SceneManager.LoadScene(levelGenerate);
}
4 - the range (2, 3) are the Index numbers of each scene
Select the Range from your Index Menu :
tag : load a random scene / level in unity. How to load random scene in unity.using C# ,how to load random scene in unity, scene manager, with scene index .
Metode 2 :
in your script just add this fonction . don't forget to add " SceneManagement" library.
public void LevelToLoad()
{
int index = Random.Range(2, 3);
SceneManager.LoadScene(index);
}
Post a Comment
image video quote pre code