Load level async
Hi, I've seen this video: https://www.youtube.com/watch?v=YMj2qPq9CP8& And I would like, instead of changing the scene showing a load bar pressing a ui button, was with a trigger. I have created two scripts, one that shows in the above mentioned video and another one that activates the other script when passing through the trigger:
Script 1 (script of the video):
public void LoadLevel (int sceneIndex)
{
StartCoroutine(LoadAsynchronously(sceneIndex));
}
IEnumerator LoadAsynchronously (int sceneIndex)
{
AsyncOperation operation = SceneManager.LoadSceneAsync(sceneIndex);
while (!operation.isDone)
{
Debug.Log(operation.progress);
yield return null;
}
}
}
Script 2 (that activates the above script with the trigger):
public class "2nd script name" : "1st script name" {
void OnTriggerEnter ()
{
LoadLevel();
}
}
I have worked by putting the value of the sceneIndex inside the script, but I do not want to repeat the same script for each scene I will do, which I want from the inspector to be able to edit "int sceneIndex" but, I have not gotten the form to do it.
I hope someone can help me. Thank you very much.