Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


GetAllScenes()

Returns an array of all the Scenes currently open in the hierarchy.
Read time 1 minuteLast updated 12 days ago

Definition

Warning
Deprecated. Use SceneManager.sceneCount and SceneManager.GetSceneAt(int index) to loop the all scenes instead.
public static Scene[] GetAllScenes()

Returns

Type

Description

Scene[]Array of Scenes in the Hierarchy.

Remarks

This list will contain all the Scenes currently open in the hierarchy. This is not necessarily the same as all the Scenes that exist in your project, or that are listed in the Build Settings.
using UnityEngine;using UnityEngine.SceneManagement;public class ExampleScript : MonoBehaviour{ void Start() { Scene[] scenes = SceneManager.GetAllScenes(); foreach (Scene sc in scenes) Debug.Log("'" + sc.name + "'"); }}
This API is obsolete. Please use SceneManager.sceneCount and SceneManager.GetSceneAt() instead.