diff --git a/Runtime/Attributes/LoadSceneAttribute.cs b/Runtime/Attributes/LoadSceneAttribute.cs index d780e08..1fd65e8 100644 --- a/Runtime/Attributes/LoadSceneAttribute.cs +++ b/Runtime/Attributes/LoadSceneAttribute.cs @@ -7,6 +7,7 @@ using System.Runtime.CompilerServices; using NUnit.Framework.Interfaces; using TestHelper.RuntimeInternals; +using UnityEngine.SceneManagement; using UnityEngine.TestTools; namespace TestHelper.Attributes @@ -45,7 +46,8 @@ public LoadSceneAttribute(string path, [CallerFilePath] string callerFilePath = public IEnumerator BeforeTest(ITest test) { // ReSharper disable once ExplicitCallerInfoArgument - yield return SceneManagerHelper.LoadSceneAsync(ScenePath, CallerFilePath); + yield return SceneManagerHelper.LoadSceneAsync(ScenePath, LoadSceneMode.Single, LocalPhysicsMode.None, + CallerFilePath); } /// diff --git a/RuntimeInternals/SceneManagerHelper.cs b/RuntimeInternals/SceneManagerHelper.cs index 0d207cd..244521a 100644 --- a/RuntimeInternals/SceneManagerHelper.cs +++ b/RuntimeInternals/SceneManagerHelper.cs @@ -35,12 +35,18 @@ public static class SceneManagerHelper /// And package name using `name` instead of `displayName`, when scenes in the package. /// (e.g., `Packages/com.nowsprinting.test-helper/Tests/Scenes/Scene.unity`) /// + /// See LoadSceneMode. Not used when called from Edit Mode tests + /// See SceneManagement.LocalPhysicsMode. Not used when called from Edit Mode tests /// /// /// When loading the scene that is not in "Scenes in Build", use . /// [SuppressMessage("ReSharper", "InvalidXmlDocComment")] - public static IEnumerator LoadSceneAsync(string path, [CallerFilePath] string callerFilePath = null) + public static IEnumerator LoadSceneAsync( + string path, + LoadSceneMode mode = LoadSceneMode.Single, + LocalPhysicsMode physicsMode = LocalPhysicsMode.None, + [CallerFilePath] string callerFilePath = null) { var existScenePath = GetExistScenePath(path, callerFilePath); AsyncOperation loadSceneAsync = null; @@ -51,21 +57,21 @@ public static IEnumerator LoadSceneAsync(string path, [CallerFilePath] string ca if (Application.isPlaying) { // Play Mode tests running in Editor - loadSceneAsync = EditorSceneManager.LoadSceneAsyncInPlayMode( - existScenePath, - new LoadSceneParameters(LoadSceneMode.Single)); + loadSceneAsync = EditorSceneManager.LoadSceneAsyncInPlayMode(existScenePath, + new LoadSceneParameters(mode, physicsMode)); } else { // Edit Mode tests - EditorSceneManager.OpenScene(existScenePath); + EditorSceneManager.OpenScene(existScenePath); // Note: Not accept LoadSceneParameters as an argument } #endif } else { // Play Mode tests running on Player - loadSceneAsync = SceneManager.LoadSceneAsync(existScenePath); + loadSceneAsync = SceneManager.LoadSceneAsync(existScenePath, + new LoadSceneParameters(mode, physicsMode)); } yield return loadSceneAsync;