Application.levelCount Manual     Reference     Scripting  
Scripting > Runtime Classes > Application
Application.levelCount

static var levelCount : int

Description

The total number of levels available (Read Only).

JavaScript
// Loads a random level

Application.LoadLevel (Random.Range(0, Application.levelCount-1));

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
void Example() {
Application.LoadLevel(Random.Range(0, Application.levelCount - 1));
}
}

import UnityEngine
import System.Collections

class example(MonoBehaviour):

def Example():
Application.LoadLevel(Random.Range(0, (Application.levelCount - 1)))