Scene.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System.Runtime.CompilerServices;
  2. namespace BansheeEngine
  3. {
  4. /// <summary>
  5. /// Handles operations with the active scene (level).
  6. /// </summary>
  7. public static class Scene
  8. {
  9. /// <summary>
  10. /// Returns the name of the scene prefab. This is empty if scene hasn't been saved yet.
  11. /// </summary>
  12. public static string ActiveSceneName { get { return activeSceneName; } }
  13. /// <summary>
  14. /// Returns the UUID of the scene prefab. This is empty if scene hasn't been saved yet.
  15. /// </summary>
  16. internal static string ActiveSceneUUID { get { return activeSceneUUID; } }
  17. private static string activeSceneName = "Unnamed";
  18. private static string activeSceneUUID = "";
  19. /// <summary>
  20. /// Clears all scene objects from the current scene.
  21. /// </summary>
  22. public static void Clear()
  23. {
  24. Internal_ClearScene();
  25. activeSceneUUID = null;
  26. activeSceneName = "Unnamed";
  27. }
  28. /// <summary>
  29. /// Loads a new scene.
  30. /// </summary>
  31. /// <param name="path">Path to the prefab to load.</param>
  32. public static void Load(string path)
  33. {
  34. Clear();
  35. Prefab scene = Internal_LoadScene(path);
  36. if (scene != null)
  37. {
  38. activeSceneUUID = scene.UUID;
  39. activeSceneName = scene.Name;
  40. }
  41. }
  42. [MethodImpl(MethodImplOptions.InternalCall)]
  43. private static extern Prefab Internal_LoadScene(string path);
  44. [MethodImpl(MethodImplOptions.InternalCall)]
  45. private static extern void Internal_ClearScene();
  46. }
  47. }