EditorScene.cs 897 B

12345678910111213141516171819202122232425262728293031
  1. using System.IO;
  2. using UnityEditor.SceneManagement;
  3. using UnityEngine.SceneManagement;
  4. namespace VEngine.Editor.Simulation
  5. {
  6. public class EditorScene : Scene
  7. {
  8. internal static Scene Create(string assetPath, bool additive = false)
  9. {
  10. if (!File.Exists(assetPath)) throw new FileNotFoundException(assetPath);
  11. var scene = new EditorScene
  12. {
  13. pathOrURL = assetPath,
  14. loadSceneMode = additive ? LoadSceneMode.Additive : LoadSceneMode.Single
  15. };
  16. return scene;
  17. }
  18. protected override void OnLoad()
  19. {
  20. PrepareToLoad();
  21. var parameters = new LoadSceneParameters
  22. {
  23. loadSceneMode = loadSceneMode
  24. };
  25. operation = EditorSceneManager.LoadSceneAsyncInPlayMode(pathOrURL, parameters);
  26. }
  27. }
  28. }