Scene.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. /// Returns the root scene object for the current scene.
  21. /// </summary>
  22. public static SceneObject Root
  23. {
  24. get { return Internal_GetRoot(); }
  25. }
  26. /// <summary>
  27. /// Clears all scene objects from the current scene.
  28. /// </summary>
  29. public static void Clear()
  30. {
  31. Internal_ClearScene();
  32. activeSceneUUID = null;
  33. activeSceneName = "Unnamed";
  34. }
  35. /// <summary>
  36. /// Loads a new scene.
  37. /// </summary>
  38. /// <param name="path">Path to the prefab to load.</param>
  39. public static void Load(string path)
  40. {
  41. Clear();
  42. Prefab scene = Internal_LoadScene(path);
  43. if (scene != null)
  44. {
  45. activeSceneUUID = scene.UUID;
  46. activeSceneName = scene.Name;
  47. }
  48. }
  49. [MethodImpl(MethodImplOptions.InternalCall)]
  50. private static extern Prefab Internal_LoadScene(string path);
  51. [MethodImpl(MethodImplOptions.InternalCall)]
  52. private static extern SceneObject Internal_GetRoot();
  53. [MethodImpl(MethodImplOptions.InternalCall)]
  54. private static extern void Internal_ClearScene();
  55. }
  56. }