i'm tring to change the restarter script by unity to instead load the next level
i want to be able to get the build number of the scene so i can then load the next level. this will allow me to use this script as a prefab therefore have infinite levels and not have to mannually change the build number ps. by build number i mean the number next to the scenes in build settings
using System; using UnityEngine;
namespace UnityStandardAssets._2D {
public class Finisher : MonoBehaviour
{
public int CurrentLevel;
private void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Player")
{
CurrentLevel = Application.loadedLevelName; //instead of getting the name i want the build number
Application.LoadLevel(CurrentLevel + 1);
}
}
}
}
Comment
Answer by g__l · Sep 02, 2015 at 06:55 PM
I am not too sure about your logic and what not, but i am only a begginner. I understand that by using Application.loadedLevel it will get your the build number rather than name. Here is the link to the scripting api http://docs.unity3d.com/ScriptReference/Application-loadedLevel.html