Legacy Documentation: Version 5.2
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Application.levelCount

Switch to Manual
public static int levelCount;

Description

The total number of levels available (Read Only).

using UnityEngine;
using System.Collections;

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