using System.Runtime.CompilerServices; namespace BansheeEngine { /// /// Handles operations with the active scene (level). /// public static class Scene { /// /// Returns the name of the scene prefab. This is empty if scene hasn't been saved yet. /// public static string ActiveSceneName { get { return activeSceneName; } } /// /// Returns the UUID of the scene prefab. This is empty if scene hasn't been saved yet. /// internal static string ActiveSceneUUID { get { return activeSceneUUID; } } private static string activeSceneName = "Unnamed"; private static string activeSceneUUID = ""; /// /// Returns the root scene object for the current scene. /// public static SceneObject Root { get { return Internal_GetRoot(); } } /// /// Returns the main camera that controls the final render surface that is displayed to the user. If the current /// scene has no main camera null is returned. /// public static Camera Camera { get { SceneObject so = Internal_GetMainCameraSO(); if (so == null) return null; return so.GetComponent(); } } /// /// Clears all scene objects from the current scene. /// public static void Clear() { Internal_ClearScene(); activeSceneUUID = null; activeSceneName = "Unnamed"; } /// /// Loads a new scene. /// /// Path to the prefab to load. public static void Load(string path) { Clear(); Prefab scene = Internal_LoadScene(path); SetActive(scene); } /// /// Sets the currently active scene to the provided scene. /// /// Scene which to set as active. internal static void SetActive(Prefab scene) { if (scene != null) { activeSceneUUID = scene.UUID; activeSceneName = scene.Name; } } [MethodImpl(MethodImplOptions.InternalCall)] private static extern Prefab Internal_LoadScene(string path); [MethodImpl(MethodImplOptions.InternalCall)] private static extern SceneObject Internal_GetRoot(); [MethodImpl(MethodImplOptions.InternalCall)] private static extern void Internal_ClearScene(); [MethodImpl(MethodImplOptions.InternalCall)] private static extern SceneObject Internal_GetMainCameraSO(); } }