From 405abed240415fefd335ba841470d7c39a8087c6 Mon Sep 17 00:00:00 2001 From: Koji Hasegawa Date: Sun, 24 Mar 2024 13:10:22 +0900 Subject: [PATCH 1/6] Refactor --- Editor/TemporaryBuildScenesUsingInTest.cs | 28 +++++++++++------------ 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Editor/TemporaryBuildScenesUsingInTest.cs b/Editor/TemporaryBuildScenesUsingInTest.cs index c8817e2..881a3e9 100644 --- a/Editor/TemporaryBuildScenesUsingInTest.cs +++ b/Editor/TemporaryBuildScenesUsingInTest.cs @@ -21,44 +21,44 @@ namespace TestHelper.Editor /// public class TemporaryBuildScenesUsingInTest : ITestPlayerBuildModifier { - private static IEnumerable FindLoadSceneAttributesOnAssemblies() + private static IEnumerable FindAttributesOnAssemblies() where T : Attribute { var assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (var attribute in assemblies - .Select(assembly => assembly.GetCustomAttributes(typeof(LoadSceneAttribute), false)) + .Select(assembly => assembly.GetCustomAttributes(typeof(T), false)) .SelectMany(attributes => attributes)) { - yield return attribute as LoadSceneAttribute; + yield return attribute as T; } } - private static IEnumerable FindLoadSceneAttributesOnTypes() + private static IEnumerable FindAttributesOnTypes() where T : Attribute { - var symbols = TypeCache.GetTypesWithAttribute(); + var symbols = TypeCache.GetTypesWithAttribute(); foreach (var attribute in symbols - .Select(symbol => symbol.GetCustomAttributes(typeof(LoadSceneAttribute), false)) + .Select(symbol => symbol.GetCustomAttributes(typeof(T), false)) .SelectMany(attributes => attributes)) { - yield return attribute as LoadSceneAttribute; + yield return attribute as T; } } - private static IEnumerable FindLoadSceneAttributesOnMethods() + private static IEnumerable FindAttributesOnMethods() where T : Attribute { - var symbols = TypeCache.GetMethodsWithAttribute(); + var symbols = TypeCache.GetMethodsWithAttribute(); foreach (var attribute in symbols - .Select(symbol => symbol.GetCustomAttributes(typeof(LoadSceneAttribute), false)) + .Select(symbol => symbol.GetCustomAttributes(typeof(T), false)) .SelectMany(attributes => attributes)) { - yield return attribute as LoadSceneAttribute; + yield return attribute as T; } } internal static IEnumerable GetScenesUsingInTest() { - var attributes = FindLoadSceneAttributesOnAssemblies() - .Concat(FindLoadSceneAttributesOnTypes()) - .Concat(FindLoadSceneAttributesOnMethods()); + var attributes = FindAttributesOnAssemblies() + .Concat(FindAttributesOnTypes()) + .Concat(FindAttributesOnMethods()); foreach (var attribute in attributes) { string scenePath; From f413192d2e438f5003b52792211ef4b382eb4471 Mon Sep 17 00:00:00 2001 From: Koji Hasegawa Date: Mon, 29 Apr 2024 12:54:22 +0900 Subject: [PATCH 2/6] Add BuildSceneAttribute --- Editor/TemporaryBuildScenesUsingInTest.cs | 8 +- README.md | 6 +- Runtime/Attributes/BuildSceneAttribute.cs | 73 +++ .../Attributes/BuildSceneAttribute.cs.meta | 3 + Runtime/Attributes/LoadSceneAttribute.cs | 64 +-- .../Attributes/BuildSceneAttributeTest.cs | 37 ++ .../BuildSceneAttributeTest.cs.meta | 3 + .../Attributes/LoadSceneAttributeTest.cs | 16 +- Tests/Scenes/NotInScenesInBuildForGlob.unity | 480 ++++++++++++++++++ .../NotInScenesInBuildForGlob.unity.meta | 7 + .../NotInScenesInBuildForRelative.unity | 480 ++++++++++++++++++ .../NotInScenesInBuildForRelative.unity.meta | 7 + Tests/Scenes/NotInScenesInBuildForUse.unity | 480 ++++++++++++++++++ .../NotInScenesInBuildForUse.unity.meta | 7 + 14 files changed, 1600 insertions(+), 71 deletions(-) create mode 100644 Runtime/Attributes/BuildSceneAttribute.cs create mode 100644 Runtime/Attributes/BuildSceneAttribute.cs.meta create mode 100644 Tests/Runtime/Attributes/BuildSceneAttributeTest.cs create mode 100644 Tests/Runtime/Attributes/BuildSceneAttributeTest.cs.meta create mode 100644 Tests/Scenes/NotInScenesInBuildForGlob.unity create mode 100644 Tests/Scenes/NotInScenesInBuildForGlob.unity.meta create mode 100644 Tests/Scenes/NotInScenesInBuildForRelative.unity create mode 100644 Tests/Scenes/NotInScenesInBuildForRelative.unity.meta create mode 100644 Tests/Scenes/NotInScenesInBuildForUse.unity create mode 100644 Tests/Scenes/NotInScenesInBuildForUse.unity.meta diff --git a/Editor/TemporaryBuildScenesUsingInTest.cs b/Editor/TemporaryBuildScenesUsingInTest.cs index 881a3e9..24deae8 100644 --- a/Editor/TemporaryBuildScenesUsingInTest.cs +++ b/Editor/TemporaryBuildScenesUsingInTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) 2023 Koji Hasegawa. +// Copyright (c) 2023-2024 Koji Hasegawa. // This software is released under the MIT License. using System; @@ -56,9 +56,9 @@ private static IEnumerable FindAttributesOnMethods() where T : Attribute internal static IEnumerable GetScenesUsingInTest() { - var attributes = FindAttributesOnAssemblies() - .Concat(FindAttributesOnTypes()) - .Concat(FindAttributesOnMethods()); + var attributes = FindAttributesOnAssemblies() + .Concat(FindAttributesOnTypes()) + .Concat(FindAttributesOnMethods()); foreach (var attribute in attributes) { string scenePath; diff --git a/README.md b/README.md index cf56ca5..f8f1d67 100644 --- a/README.md +++ b/README.md @@ -217,10 +217,10 @@ It has the following benefits: - Can be use same code for running Edit Mode tests, Play Mode tests in Editor, and on Player. - Can be specified scenes that are **NOT** in "Scenes in Build". -- Can be specified path by glob pattern. However, there are restrictions, top level and scene name cannot be omitted. -- Can be specified path by relative path from the test class file. +- Can be specified scene path by [glob](https://en.wikipedia.org/wiki/Glob_(programming)) pattern. However, there are restrictions, top level and scene name cannot be omitted. +- Can be specified scene path by relative path from the test class file. -- This attribute can attached to the test method only. +This attribute can attached to the test method only. It can be used with sync Tests, async Tests, and UnityTest. Usage: diff --git a/Runtime/Attributes/BuildSceneAttribute.cs b/Runtime/Attributes/BuildSceneAttribute.cs new file mode 100644 index 0000000..f0f38a3 --- /dev/null +++ b/Runtime/Attributes/BuildSceneAttribute.cs @@ -0,0 +1,73 @@ +// Copyright (c) 2023-2024 Koji Hasegawa. +// This software is released under the MIT License. + +using System; +using System.Diagnostics.CodeAnalysis; +using System.IO; +using System.Runtime.CompilerServices; +using NUnit.Framework; +using UnityEngine; + +namespace TestHelper.Attributes +{ + /// + /// Build scene before running test on player. + /// + [AttributeUsage(AttributeTargets.Method)] + public class BuildSceneAttribute : NUnitAttribute + { + internal string ScenePath { get; private set; } + + /// + /// Build scene before running test on player. + /// This attribute has the following benefits: + /// - Can be specified scenes that are **NOT** in "Scenes in Build". + /// - Can be specified scene path by [glob](https://en.wikipedia.org/wiki/Glob_(programming)) pattern. However, there are restrictions, top level and scene name cannot be omitted. + /// - Can be specified scene path by relative path from the test class file. + /// + /// Scene file path. + /// The path starts with `Assets/` or `Packages/` or `.`. + /// And package name using `name` instead of `displayName`, when scenes in the package. + /// (e.g., `Packages/com.nowsprinting.test-helper/Tests/Scenes/Scene.unity`) + /// + /// + /// - For the process of including a Scene not in "Scenes in Build" to a build for player, see: . + /// + [SuppressMessage("ReSharper", "InvalidXmlDocComment")] + public BuildSceneAttribute(string path, [CallerFilePath] string callerFilePath = null) + { + if (path.StartsWith(".")) + { + ScenePath = GetAbsolutePath(path, callerFilePath); + } + else + { + ScenePath = path; + } + } + + [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] + internal static string GetAbsolutePath(string relativePath, string callerFilePath) + { + var callerDirectory = Path.GetDirectoryName(callerFilePath); + var absolutePath = Path.GetFullPath(Path.Combine(callerDirectory, relativePath)); + + var assetsIndexOf = absolutePath.IndexOf("Assets", StringComparison.Ordinal); + if (assetsIndexOf > 0) + { + return absolutePath.Substring(assetsIndexOf); + } + + var packageIndexOf = absolutePath.IndexOf("Packages", StringComparison.Ordinal); + if (packageIndexOf > 0) + { + return absolutePath.Substring(packageIndexOf); + } + + Debug.LogError( + $"Can not resolve absolute path. relativePath: {relativePath}, callerFilePath: {callerFilePath}"); + return null; + // Note: Do not use Exception (and Assert). Because freezes async tests on UTF v1.3.4, See UUM-25085. + } + } +} diff --git a/Runtime/Attributes/BuildSceneAttribute.cs.meta b/Runtime/Attributes/BuildSceneAttribute.cs.meta new file mode 100644 index 0000000..d47fa1a --- /dev/null +++ b/Runtime/Attributes/BuildSceneAttribute.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a41ca53cb4a74fb28baa6f0dc03d2cfd +timeCreated: 1714362832 \ No newline at end of file diff --git a/Runtime/Attributes/LoadSceneAttribute.cs b/Runtime/Attributes/LoadSceneAttribute.cs index 2302b1e..e0a05de 100644 --- a/Runtime/Attributes/LoadSceneAttribute.cs +++ b/Runtime/Attributes/LoadSceneAttribute.cs @@ -4,82 +4,46 @@ using System; using System.Collections; using System.Diagnostics.CodeAnalysis; -using System.IO; using System.Runtime.CompilerServices; -using NUnit.Framework; using NUnit.Framework.Interfaces; using TestHelper.Utils; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.TestTools; #if UNITY_EDITOR -using UnityEditor; using UnityEditor.SceneManagement; #endif -// ReSharper disable InvalidXmlDocComment - namespace TestHelper.Attributes { /// /// Load scene before running test. - /// - /// It has the following benefits: - /// - Can be used when running play mode tests in-editor and on-player - /// - Can be specified scenes that are not in "Scenes in Build" - /// - /// Notes: - /// - Load scene run after OneTimeSetUp and before SetUp - /// - For the process of including a Scene not in "Scenes in Build" to a build for player, see: /// [AttributeUsage(AttributeTargets.Method)] - public class LoadSceneAttribute : NUnitAttribute, IOuterUnityTestAction + public class LoadSceneAttribute : BuildSceneAttribute, IOuterUnityTestAction { - internal string ScenePath { get; private set; } - /// /// Load scene before running test. - /// Can be specified path by glob pattern. However, there are restrictions, top level and scene name cannot be omitted. - /// Can be specified relative path. + /// This attribute has the following benefits: + /// - Can be use same code for running Edit Mode tests, Play Mode tests in Editor, and on Player. + /// - Can be specified scenes that are **NOT** in "Scenes in Build". + /// - Can be specified scene path by [glob](https://en.wikipedia.org/wiki/Glob_(programming)) pattern. However, there are restrictions, top level and scene name cannot be omitted. + /// - Can be specified scene path by relative path from the test class file. /// /// Scene file path. - /// The path starts with `Assets/` or `Packages/`. + /// The path starts with `Assets/` or `Packages/` or `.`. /// And package name using `name` instead of `displayName`, when scenes in the package. /// (e.g., `Packages/com.nowsprinting.test-helper/Tests/Scenes/Scene.unity`) /// - /// + /// + /// - Load scene run after OneTimeSetUp and before SetUp. + /// - For the process of including a Scene not in "Scenes in Build" to a build for player, see: . + /// + [SuppressMessage("ReSharper", "ExplicitCallerInfoArgument")] + [SuppressMessage("ReSharper", "InvalidXmlDocComment")] public LoadSceneAttribute(string path, [CallerFilePath] string callerFilePath = null) + : base(path, callerFilePath) { - if (path.StartsWith(".")) - { - ScenePath = GetAbsolutePath(path, callerFilePath); - } - else - { - ScenePath = path; - } - } - - [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] - internal static string GetAbsolutePath(string relativePath, string callerFilePath) - { - var callerDirectory = Path.GetDirectoryName(callerFilePath); - var absolutePath = Path.GetFullPath(Path.Combine(callerDirectory, relativePath)); - - var assetsIndexOf = absolutePath.IndexOf("Assets", StringComparison.Ordinal); - if (assetsIndexOf > 0) - { - return absolutePath.Substring(assetsIndexOf); - } - - var packageIndexOf = absolutePath.IndexOf("Packages", StringComparison.Ordinal); - if (packageIndexOf > 0) - { - return absolutePath.Substring(packageIndexOf); - } - - throw new ArgumentException( - $"Can not resolve absolute path. relativePath: {relativePath}, callerFilePath: {callerFilePath}"); } /// diff --git a/Tests/Runtime/Attributes/BuildSceneAttributeTest.cs b/Tests/Runtime/Attributes/BuildSceneAttributeTest.cs new file mode 100644 index 0000000..eea8be4 --- /dev/null +++ b/Tests/Runtime/Attributes/BuildSceneAttributeTest.cs @@ -0,0 +1,37 @@ +// Copyright (c) 2023-2024 Koji Hasegawa. +// This software is released under the MIT License. + +using NUnit.Framework; +using UnityEngine; + +namespace TestHelper.Attributes +{ + /// + [TestFixture] + public class BuildSceneAttributeTest + { + private const string ObjectName = "CubeInNotInScenesInBuild"; + + [Test] + [BuildScene("Packages/com.nowsprinting.test-helper/Tests/Scenes/NotInScenesInBuildForUse.unity")] + public void Attach_BuildScene() + { + var cube = GameObject.Find(ObjectName); + Assume.That(cube, Is.Null, "Not loaded "); + + // TODO: Load scene + } + + [TestCase("./Scene.unity", // include `./` + "Assets/Tests/Runtime/Caller.cs", + "Assets/Tests/Runtime/Scene.unity")] + [TestCase("../../BadPath/../Scenes/Scene.unity", // include `../` + "Packages/com.nowsprinting.test-helper/Tests/Runtime/Attributes/Caller.cs", + "Packages/com.nowsprinting.test-helper/Tests/Scenes/Scene.unity")] + public void GetAbsolutePath(string relativePath, string callerFilePath, string expected) + { + var actual = BuildSceneAttribute.GetAbsolutePath(relativePath, callerFilePath); + Assert.That(actual, Is.EqualTo(expected)); + } + } +} diff --git a/Tests/Runtime/Attributes/BuildSceneAttributeTest.cs.meta b/Tests/Runtime/Attributes/BuildSceneAttributeTest.cs.meta new file mode 100644 index 0000000..de23bb9 --- /dev/null +++ b/Tests/Runtime/Attributes/BuildSceneAttributeTest.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 107c5cb6460248c7912bec5795a0b3c4 +timeCreated: 1714365787 \ No newline at end of file diff --git a/Tests/Runtime/Attributes/LoadSceneAttributeTest.cs b/Tests/Runtime/Attributes/LoadSceneAttributeTest.cs index 18abe14..636f488 100644 --- a/Tests/Runtime/Attributes/LoadSceneAttributeTest.cs +++ b/Tests/Runtime/Attributes/LoadSceneAttributeTest.cs @@ -48,7 +48,7 @@ public IEnumerator AttachToUnityTest_LoadedSceneNotInBuild() } [Test] - [LoadScene("Packages/com.nowsprinting.test-helper/**/NotInScenesInBuild.unity")] + [LoadScene("Packages/com.nowsprinting.test-helper/**/NotInScenesInBuildForGlob.unity")] public void UsingGlob_LoadedSceneNotInBuild() { var cube = GameObject.Find(ObjectName); @@ -58,7 +58,7 @@ public void UsingGlob_LoadedSceneNotInBuild() } [Test] - [LoadScene("../../Scenes/NotInScenesInBuild.unity")] + [LoadScene("../../Scenes/NotInScenesInBuildForRelative.unity")] public void UsingRelativePath_LoadedSceneNotInBuild() { var cube = GameObject.Find(ObjectName); @@ -66,17 +66,5 @@ public void UsingRelativePath_LoadedSceneNotInBuild() Object.Destroy(cube); // For not giving false negatives in subsequent tests. } - - [TestCase("./Scene.unity", // include `./` - "Assets/Tests/Runtime/Caller.cs", - "Assets/Tests/Runtime/Scene.unity")] - [TestCase("../../BadPath/../Scenes/Scene.unity", // include `../` - "Packages/com.nowsprinting.test-helper/Tests/Runtime/Attributes/Caller.cs", - "Packages/com.nowsprinting.test-helper/Tests/Scenes/Scene.unity")] - public void GetAbsolutePath(string relativePath, string callerFilePath, string expected) - { - var actual = LoadSceneAttribute.GetAbsolutePath(relativePath, callerFilePath); - Assert.That(actual, Is.EqualTo(expected)); - } } } diff --git a/Tests/Scenes/NotInScenesInBuildForGlob.unity b/Tests/Scenes/NotInScenesInBuildForGlob.unity new file mode 100644 index 0000000..c839fce --- /dev/null +++ b/Tests/Scenes/NotInScenesInBuildForGlob.unity @@ -0,0 +1,480 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0.44657838, g: 0.49641228, b: 0.57481676, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 12 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 0} + m_LightingSettings: {fileID: 629626379} +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 3 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + buildHeightMesh: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!850595691 &629626379 +LightingSettings: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + serializedVersion: 6 + m_GIWorkflowMode: 1 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_RealtimeEnvironmentLighting: 1 + m_BounceScale: 1 + m_AlbedoBoost: 1 + m_IndirectOutputScale: 1 + m_UsingShadowmask: 1 + m_BakeBackend: 1 + m_LightmapMaxSize: 1024 + m_BakeResolution: 40 + m_Padding: 2 + m_LightmapCompression: 3 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAO: 0 + m_MixedBakeMode: 2 + m_LightmapsBakeMode: 1 + m_FilterMode: 1 + m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0} + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_RealtimeResolution: 2 + m_ForceWhiteAlbedo: 0 + m_ForceUpdates: 0 + m_FinalGather: 0 + m_FinalGatherRayCount: 256 + m_FinalGatherFiltering: 1 + m_PVRCulling: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_LightProbeSampleCountMultiplier: 4 + m_PVRBounces: 2 + m_PVRMinBounces: 2 + m_PVREnvironmentImportanceSampling: 1 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_PVRTiledBaking: 0 + m_NumRaysToShootPerTexel: -1 + m_RespectSceneVisibilityWhenBakingGI: 0 +--- !u!1 &662139854 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 662139857} + - component: {fileID: 662139856} + - component: {fileID: 662139855} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &662139855 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 662139854} + m_Enabled: 1 +--- !u!20 &662139856 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 662139854} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_Iso: 200 + m_ShutterSpeed: 0.005 + m_Aperture: 16 + m_FocusDistance: 10 + m_FocalLength: 50 + m_BladeCount: 5 + m_Curvature: {x: 2, y: 11} + m_BarrelClipping: 0.25 + m_Anamorphism: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &662139857 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 662139854} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &981211536 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 981211540} + - component: {fileID: 981211539} + - component: {fileID: 981211538} + - component: {fileID: 981211537} + m_Layer: 0 + m_Name: CubeInNotInScenesInBuild + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!65 &981211537 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 981211536} + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 0 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 3 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!23 &981211538 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 981211536} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &981211539 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 981211536} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &981211540 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 981211536} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1407779068 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1407779070} + - component: {fileID: 1407779069} + m_Layer: 0 + m_Name: Directional Light + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!108 &1407779069 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1407779068} + m_Enabled: 1 + serializedVersion: 10 + m_Type: 1 + m_Shape: 0 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_InnerSpotAngle: 21.80208 + m_CookieSize: 10 + m_Shadows: + m_Type: 2 + m_Resolution: -1 + m_CustomResolution: -1 + m_Strength: 1 + m_Bias: 0.05 + m_NormalBias: 0.4 + m_NearPlane: 0.2 + m_CullingMatrixOverride: + e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + m_UseCullingMatrixOverride: 0 + m_Cookie: {fileID: 0} + m_DrawHalo: 0 + m_Flare: {fileID: 0} + m_RenderMode: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingLayerMask: 1 + m_Lightmapping: 4 + m_LightShadowCasterMode: 0 + m_AreaSize: {x: 1, y: 1} + m_BounceIntensity: 1 + m_ColorTemperature: 6570 + m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} + m_UseBoundingSphereOverride: 0 + m_UseViewFrustumForShadowCasterCull: 1 + m_ShadowRadius: 0 + m_ShadowAngle: 0 +--- !u!4 &1407779070 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1407779068} + m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} + m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} diff --git a/Tests/Scenes/NotInScenesInBuildForGlob.unity.meta b/Tests/Scenes/NotInScenesInBuildForGlob.unity.meta new file mode 100644 index 0000000..4d7758d --- /dev/null +++ b/Tests/Scenes/NotInScenesInBuildForGlob.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 57baa7f9a542e49f39ee705d1cf417e4 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tests/Scenes/NotInScenesInBuildForRelative.unity b/Tests/Scenes/NotInScenesInBuildForRelative.unity new file mode 100644 index 0000000..c839fce --- /dev/null +++ b/Tests/Scenes/NotInScenesInBuildForRelative.unity @@ -0,0 +1,480 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0.44657838, g: 0.49641228, b: 0.57481676, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 12 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 0} + m_LightingSettings: {fileID: 629626379} +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 3 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + buildHeightMesh: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!850595691 &629626379 +LightingSettings: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + serializedVersion: 6 + m_GIWorkflowMode: 1 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_RealtimeEnvironmentLighting: 1 + m_BounceScale: 1 + m_AlbedoBoost: 1 + m_IndirectOutputScale: 1 + m_UsingShadowmask: 1 + m_BakeBackend: 1 + m_LightmapMaxSize: 1024 + m_BakeResolution: 40 + m_Padding: 2 + m_LightmapCompression: 3 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAO: 0 + m_MixedBakeMode: 2 + m_LightmapsBakeMode: 1 + m_FilterMode: 1 + m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0} + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_RealtimeResolution: 2 + m_ForceWhiteAlbedo: 0 + m_ForceUpdates: 0 + m_FinalGather: 0 + m_FinalGatherRayCount: 256 + m_FinalGatherFiltering: 1 + m_PVRCulling: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_LightProbeSampleCountMultiplier: 4 + m_PVRBounces: 2 + m_PVRMinBounces: 2 + m_PVREnvironmentImportanceSampling: 1 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_PVRTiledBaking: 0 + m_NumRaysToShootPerTexel: -1 + m_RespectSceneVisibilityWhenBakingGI: 0 +--- !u!1 &662139854 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 662139857} + - component: {fileID: 662139856} + - component: {fileID: 662139855} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &662139855 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 662139854} + m_Enabled: 1 +--- !u!20 &662139856 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 662139854} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_Iso: 200 + m_ShutterSpeed: 0.005 + m_Aperture: 16 + m_FocusDistance: 10 + m_FocalLength: 50 + m_BladeCount: 5 + m_Curvature: {x: 2, y: 11} + m_BarrelClipping: 0.25 + m_Anamorphism: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &662139857 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 662139854} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &981211536 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 981211540} + - component: {fileID: 981211539} + - component: {fileID: 981211538} + - component: {fileID: 981211537} + m_Layer: 0 + m_Name: CubeInNotInScenesInBuild + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!65 &981211537 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 981211536} + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 0 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 3 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!23 &981211538 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 981211536} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &981211539 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 981211536} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &981211540 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 981211536} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1407779068 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1407779070} + - component: {fileID: 1407779069} + m_Layer: 0 + m_Name: Directional Light + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!108 &1407779069 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1407779068} + m_Enabled: 1 + serializedVersion: 10 + m_Type: 1 + m_Shape: 0 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_InnerSpotAngle: 21.80208 + m_CookieSize: 10 + m_Shadows: + m_Type: 2 + m_Resolution: -1 + m_CustomResolution: -1 + m_Strength: 1 + m_Bias: 0.05 + m_NormalBias: 0.4 + m_NearPlane: 0.2 + m_CullingMatrixOverride: + e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + m_UseCullingMatrixOverride: 0 + m_Cookie: {fileID: 0} + m_DrawHalo: 0 + m_Flare: {fileID: 0} + m_RenderMode: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingLayerMask: 1 + m_Lightmapping: 4 + m_LightShadowCasterMode: 0 + m_AreaSize: {x: 1, y: 1} + m_BounceIntensity: 1 + m_ColorTemperature: 6570 + m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} + m_UseBoundingSphereOverride: 0 + m_UseViewFrustumForShadowCasterCull: 1 + m_ShadowRadius: 0 + m_ShadowAngle: 0 +--- !u!4 &1407779070 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1407779068} + m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} + m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} diff --git a/Tests/Scenes/NotInScenesInBuildForRelative.unity.meta b/Tests/Scenes/NotInScenesInBuildForRelative.unity.meta new file mode 100644 index 0000000..61281e5 --- /dev/null +++ b/Tests/Scenes/NotInScenesInBuildForRelative.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: d879e62eb359144bda460d1fa5f0f75d +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tests/Scenes/NotInScenesInBuildForUse.unity b/Tests/Scenes/NotInScenesInBuildForUse.unity new file mode 100644 index 0000000..c839fce --- /dev/null +++ b/Tests/Scenes/NotInScenesInBuildForUse.unity @@ -0,0 +1,480 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0.44657838, g: 0.49641228, b: 0.57481676, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 12 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 0} + m_LightingSettings: {fileID: 629626379} +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 3 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + buildHeightMesh: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!850595691 &629626379 +LightingSettings: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + serializedVersion: 6 + m_GIWorkflowMode: 1 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_RealtimeEnvironmentLighting: 1 + m_BounceScale: 1 + m_AlbedoBoost: 1 + m_IndirectOutputScale: 1 + m_UsingShadowmask: 1 + m_BakeBackend: 1 + m_LightmapMaxSize: 1024 + m_BakeResolution: 40 + m_Padding: 2 + m_LightmapCompression: 3 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAO: 0 + m_MixedBakeMode: 2 + m_LightmapsBakeMode: 1 + m_FilterMode: 1 + m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0} + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_RealtimeResolution: 2 + m_ForceWhiteAlbedo: 0 + m_ForceUpdates: 0 + m_FinalGather: 0 + m_FinalGatherRayCount: 256 + m_FinalGatherFiltering: 1 + m_PVRCulling: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_LightProbeSampleCountMultiplier: 4 + m_PVRBounces: 2 + m_PVRMinBounces: 2 + m_PVREnvironmentImportanceSampling: 1 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_PVRTiledBaking: 0 + m_NumRaysToShootPerTexel: -1 + m_RespectSceneVisibilityWhenBakingGI: 0 +--- !u!1 &662139854 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 662139857} + - component: {fileID: 662139856} + - component: {fileID: 662139855} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &662139855 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 662139854} + m_Enabled: 1 +--- !u!20 &662139856 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 662139854} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_Iso: 200 + m_ShutterSpeed: 0.005 + m_Aperture: 16 + m_FocusDistance: 10 + m_FocalLength: 50 + m_BladeCount: 5 + m_Curvature: {x: 2, y: 11} + m_BarrelClipping: 0.25 + m_Anamorphism: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &662139857 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 662139854} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &981211536 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 981211540} + - component: {fileID: 981211539} + - component: {fileID: 981211538} + - component: {fileID: 981211537} + m_Layer: 0 + m_Name: CubeInNotInScenesInBuild + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!65 &981211537 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 981211536} + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 0 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 3 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!23 &981211538 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 981211536} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &981211539 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 981211536} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &981211540 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 981211536} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1407779068 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1407779070} + - component: {fileID: 1407779069} + m_Layer: 0 + m_Name: Directional Light + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!108 &1407779069 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1407779068} + m_Enabled: 1 + serializedVersion: 10 + m_Type: 1 + m_Shape: 0 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_InnerSpotAngle: 21.80208 + m_CookieSize: 10 + m_Shadows: + m_Type: 2 + m_Resolution: -1 + m_CustomResolution: -1 + m_Strength: 1 + m_Bias: 0.05 + m_NormalBias: 0.4 + m_NearPlane: 0.2 + m_CullingMatrixOverride: + e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + m_UseCullingMatrixOverride: 0 + m_Cookie: {fileID: 0} + m_DrawHalo: 0 + m_Flare: {fileID: 0} + m_RenderMode: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingLayerMask: 1 + m_Lightmapping: 4 + m_LightShadowCasterMode: 0 + m_AreaSize: {x: 1, y: 1} + m_BounceIntensity: 1 + m_ColorTemperature: 6570 + m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} + m_UseBoundingSphereOverride: 0 + m_UseViewFrustumForShadowCasterCull: 1 + m_ShadowRadius: 0 + m_ShadowAngle: 0 +--- !u!4 &1407779070 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1407779068} + m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} + m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} diff --git a/Tests/Scenes/NotInScenesInBuildForUse.unity.meta b/Tests/Scenes/NotInScenesInBuildForUse.unity.meta new file mode 100644 index 0000000..211c65b --- /dev/null +++ b/Tests/Scenes/NotInScenesInBuildForUse.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 04402e0eb57484956bcd85535d57faca +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: From f6ca2d8b24ef7b3073a57172fa167956b61b72d0 Mon Sep 17 00:00:00 2001 From: Koji Hasegawa Date: Mon, 29 Apr 2024 15:19:55 +0900 Subject: [PATCH 3/6] Mod extract LoadSceneCoroutine method to SceneManagerHelper class (rename from ScenePathFinder) --- Editor/TemporaryBuildScenesUsingInTest.cs | 4 +- Editor/TestHelper.Editor.asmdef | 3 +- Runtime/Attributes/LoadSceneAttribute.cs | 35 +---------- Runtime/Utils/ScenePathFinder.cs.meta | 3 - .../SceneManagerHelper.cs | 60 ++++++++++++++++++- RuntimeInternals/SceneManagerHelper.cs.meta | 3 + .../Attributes/BuildSceneAttributeTest.cs | 12 +++- Tests/Runtime/Utils.meta | 3 - .../SceneManagerHelperTest.cs} | 30 ++++++++-- .../SceneManagerHelperTest.cs.meta} | 0 10 files changed, 100 insertions(+), 53 deletions(-) delete mode 100644 Runtime/Utils/ScenePathFinder.cs.meta rename Runtime/Utils/ScenePathFinder.cs => RuntimeInternals/SceneManagerHelper.cs (65%) create mode 100644 RuntimeInternals/SceneManagerHelper.cs.meta delete mode 100644 Tests/Runtime/Utils.meta rename Tests/{Runtime/Utils/ScenePathFinderTest.cs => RuntimeInternals/SceneManagerHelperTest.cs} (65%) rename Tests/{Runtime/Utils/ScenePathFinderTest.cs.meta => RuntimeInternals/SceneManagerHelperTest.cs.meta} (100%) diff --git a/Editor/TemporaryBuildScenesUsingInTest.cs b/Editor/TemporaryBuildScenesUsingInTest.cs index 24deae8..12f7953 100644 --- a/Editor/TemporaryBuildScenesUsingInTest.cs +++ b/Editor/TemporaryBuildScenesUsingInTest.cs @@ -7,7 +7,7 @@ using System.Linq; using TestHelper.Attributes; using TestHelper.Editor; -using TestHelper.Utils; +using TestHelper.RuntimeInternals; using UnityEditor; using UnityEditor.TestTools; using UnityEngine; @@ -64,7 +64,7 @@ internal static IEnumerable GetScenesUsingInTest() string scenePath; try { - scenePath = ScenePathFinder.GetExistScenePath(attribute.ScenePath); + scenePath = SceneManagerHelper.GetExistScenePath(attribute.ScenePath); } catch (ArgumentException e) { diff --git a/Editor/TestHelper.Editor.asmdef b/Editor/TestHelper.Editor.asmdef index b65c768..f525488 100644 --- a/Editor/TestHelper.Editor.asmdef +++ b/Editor/TestHelper.Editor.asmdef @@ -2,7 +2,8 @@ "name": "TestHelper.Editor", "rootNamespace": "TestHelper", "references": [ - "TestHelper" + "TestHelper", + "TestHelper.RuntimeInternals" ], "includePlatforms": [ "Editor" diff --git a/Runtime/Attributes/LoadSceneAttribute.cs b/Runtime/Attributes/LoadSceneAttribute.cs index e0a05de..b68146c 100644 --- a/Runtime/Attributes/LoadSceneAttribute.cs +++ b/Runtime/Attributes/LoadSceneAttribute.cs @@ -6,13 +6,8 @@ using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using NUnit.Framework.Interfaces; -using TestHelper.Utils; -using UnityEngine; -using UnityEngine.SceneManagement; +using TestHelper.RuntimeInternals; using UnityEngine.TestTools; -#if UNITY_EDITOR -using UnityEditor.SceneManagement; -#endif namespace TestHelper.Attributes { @@ -49,33 +44,7 @@ public LoadSceneAttribute(string path, [CallerFilePath] string callerFilePath = /// public IEnumerator BeforeTest(ITest test) { - var existScenePath = ScenePathFinder.GetExistScenePath(ScenePath); - AsyncOperation loadSceneAsync = null; - - if (Application.isEditor) - { -#if UNITY_EDITOR - if (Application.isPlaying) - { - // Play Mode tests running in Editor - loadSceneAsync = EditorSceneManager.LoadSceneAsyncInPlayMode( - existScenePath, - new LoadSceneParameters(LoadSceneMode.Single)); - } - else - { - // Edit Mode tests - EditorSceneManager.OpenScene(existScenePath); - } -#endif - } - else - { - // Play Mode tests running on Player - loadSceneAsync = SceneManager.LoadSceneAsync(existScenePath); - } - - yield return loadSceneAsync; + yield return SceneManagerHelper.LoadSceneCoroutine(ScenePath); } /// diff --git a/Runtime/Utils/ScenePathFinder.cs.meta b/Runtime/Utils/ScenePathFinder.cs.meta deleted file mode 100644 index df14c41..0000000 --- a/Runtime/Utils/ScenePathFinder.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 6038685c18ff47b2b5cfde489f9dedac -timeCreated: 1711253913 \ No newline at end of file diff --git a/Runtime/Utils/ScenePathFinder.cs b/RuntimeInternals/SceneManagerHelper.cs similarity index 65% rename from Runtime/Utils/ScenePathFinder.cs rename to RuntimeInternals/SceneManagerHelper.cs index 576b121..b2f47cb 100644 --- a/Runtime/Utils/ScenePathFinder.cs +++ b/RuntimeInternals/SceneManagerHelper.cs @@ -2,18 +2,74 @@ // This software is released under the MIT License. using System; +using System.Collections; +using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Text; using System.Text.RegularExpressions; +using UnityEngine; +using UnityEngine.SceneManagement; #if UNITY_EDITOR using UnityEditor; +using UnityEditor.SceneManagement; #endif -namespace TestHelper.Utils +namespace TestHelper.RuntimeInternals { - internal static class ScenePathFinder + /// + /// Helper class for scene management. + /// + public static class SceneManagerHelper { + /// + /// Loading scene file. + /// This attribute has the following benefits: + /// - Can be use same code for running Edit Mode tests, Play Mode tests in Editor, and on Player. + /// - Can be specified scene path by [glob](https://en.wikipedia.org/wiki/Glob_(programming)) pattern. However, there are restrictions, top level and scene name cannot be omitted. + /// - Can be specified scene path by relative path from the test class file. + /// + /// Scene file path. + /// The path starts with `Assets/` or `Packages/` or `.`. + /// And package name using `name` instead of `displayName`, when scenes in the package. + /// (e.g., `Packages/com.nowsprinting.test-helper/Tests/Scenes/Scene.unity`) + /// + /// + /// + /// When loading the scene that is not in "Scenes in Build", use . + /// + [SuppressMessage("ReSharper", "InvalidXmlDocComment")] + public static IEnumerator LoadSceneCoroutine(string path) + { + var existScenePath = GetExistScenePath(path); + AsyncOperation loadSceneAsync = null; + + if (Application.isEditor) + { +#if UNITY_EDITOR + if (Application.isPlaying) + { + // Play Mode tests running in Editor + loadSceneAsync = EditorSceneManager.LoadSceneAsyncInPlayMode( + existScenePath, + new LoadSceneParameters(LoadSceneMode.Single)); + } + else + { + // Edit Mode tests + EditorSceneManager.OpenScene(existScenePath); + } +#endif + } + else + { + // Play Mode tests running on Player + loadSceneAsync = SceneManager.LoadSceneAsync(existScenePath); + } + + yield return loadSceneAsync; + } + /// /// Get existing scene file path matches a glob pattern. /// diff --git a/RuntimeInternals/SceneManagerHelper.cs.meta b/RuntimeInternals/SceneManagerHelper.cs.meta new file mode 100644 index 0000000..7dc39b9 --- /dev/null +++ b/RuntimeInternals/SceneManagerHelper.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 948e9c7041e849faaede0c996aac3bb1 +timeCreated: 1714370235 \ No newline at end of file diff --git a/Tests/Runtime/Attributes/BuildSceneAttributeTest.cs b/Tests/Runtime/Attributes/BuildSceneAttributeTest.cs index eea8be4..5e7aa68 100644 --- a/Tests/Runtime/Attributes/BuildSceneAttributeTest.cs +++ b/Tests/Runtime/Attributes/BuildSceneAttributeTest.cs @@ -1,7 +1,10 @@ // Copyright (c) 2023-2024 Koji Hasegawa. // This software is released under the MIT License. +using System.Threading.Tasks; +using Cysharp.Threading.Tasks; using NUnit.Framework; +using TestHelper.RuntimeInternals; using UnityEngine; namespace TestHelper.Attributes @@ -10,16 +13,19 @@ namespace TestHelper.Attributes [TestFixture] public class BuildSceneAttributeTest { + private const string TestScene = "../../Scenes/NotInScenesInBuildForUse.unity"; private const string ObjectName = "CubeInNotInScenesInBuild"; [Test] - [BuildScene("Packages/com.nowsprinting.test-helper/Tests/Scenes/NotInScenesInBuildForUse.unity")] - public void Attach_BuildScene() + [BuildScene(TestScene)] + public async Task Attach_SceneIntoBuild() { var cube = GameObject.Find(ObjectName); Assume.That(cube, Is.Null, "Not loaded "); - // TODO: Load scene + await SceneManagerHelper.LoadSceneCoroutine(TestScene); // Can also be loaded by running the player + cube = GameObject.Find(ObjectName); + Assume.That(cube, Is.Not.Null); } [TestCase("./Scene.unity", // include `./` diff --git a/Tests/Runtime/Utils.meta b/Tests/Runtime/Utils.meta deleted file mode 100644 index c6e73fb..0000000 --- a/Tests/Runtime/Utils.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 14bd4144206d412ba38950fc3ea64b0a -timeCreated: 1711257235 \ No newline at end of file diff --git a/Tests/Runtime/Utils/ScenePathFinderTest.cs b/Tests/RuntimeInternals/SceneManagerHelperTest.cs similarity index 65% rename from Tests/Runtime/Utils/ScenePathFinderTest.cs rename to Tests/RuntimeInternals/SceneManagerHelperTest.cs index e9e3d95..70590dd 100644 --- a/Tests/Runtime/Utils/ScenePathFinderTest.cs +++ b/Tests/RuntimeInternals/SceneManagerHelperTest.cs @@ -3,15 +3,33 @@ using System; using System.IO; +using System.Threading.Tasks; +using Cysharp.Threading.Tasks; using NUnit.Framework; using UnityEngine; using UnityEngine.TestTools; -namespace TestHelper.Utils +namespace TestHelper.RuntimeInternals { [TestFixture] - public class ScenePathFinderTest + public class SceneManagerHelperTest { + [Test] + [UnityPlatform(RuntimePlatform.OSXEditor, RuntimePlatform.WindowsEditor, RuntimePlatform.LinuxEditor)] + // Note: Tests to run on the player, see `BuildSceneAttributeTest` + public async Task LoadSceneCoroutine_LoadedScene() + { + const string TestScene = "../Scenes/NotInScenesInBuildForUse.unity"; + const string ObjectName = "CubeInNotInScenesInBuild"; + + var cube = GameObject.Find(ObjectName); + Assume.That(cube, Is.Null, "Not loaded "); + + await SceneManagerHelper.LoadSceneCoroutine(TestScene); + cube = GameObject.Find(ObjectName); + Assume.That(cube, Is.Not.Null); + } + [TestCase("Packages/com.nowsprinting.test-helper/Tests/Scenes/NotInScenesInBuild.unity")] [TestCase("Packages/com.nowsprinting.test-helper/Tes?s/S?enes/NotInScenesInBuild.unity")] [TestCase("Packages/com.nowsprinting.test-helper/*/*/NotInScenesInBuild.unity")] @@ -24,7 +42,7 @@ public void GetExistScenePath_ExistPath_GotExistScenePath(string path) const string ExistScenePath = "NotInScenesInBuild"; // Scene name only #endif - var actual = ScenePathFinder.GetExistScenePath(path); + var actual = SceneManagerHelper.GetExistScenePath(path); Assert.That(actual, Is.EqualTo(ExistScenePath)); } @@ -35,7 +53,7 @@ public void GetExistScenePath_ExistPath_GotExistScenePath(string path) [TestCase("Packages/com.nowsprinting.test-helper/Tests/Scenes/*InScenesInBuild.unity")] public void GetExistScenePath_InvalidGlobPattern_ThrowsArgumentException(string path) { - Assert.That(() => ScenePathFinder.GetExistScenePath(path), Throws.TypeOf()); + Assert.That(() => SceneManagerHelper.GetExistScenePath(path), Throws.TypeOf()); } [TestCase("Packages/com.nowsprinting.test-helper/Tests/Scenes/NotExistScene.unity")] // Not exist path @@ -43,7 +61,7 @@ public void GetExistScenePath_InvalidGlobPattern_ThrowsArgumentException(string [UnityPlatform(RuntimePlatform.OSXEditor, RuntimePlatform.WindowsEditor, RuntimePlatform.LinuxEditor)] public void GetExistScenePath_NotExistPath_InEditor_ThrowsFileNotFoundException(string path) { - Assert.That(() => ScenePathFinder.GetExistScenePath(path), Throws.TypeOf()); + Assert.That(() => SceneManagerHelper.GetExistScenePath(path), Throws.TypeOf()); // Note: Returns scene name when running on player. } @@ -52,7 +70,7 @@ public void GetExistScenePathOnPlayer_GotSceneName(string path) { const string SceneName = "NotInScenesInBuild"; - var actual = ScenePathFinder.GetExistScenePathOnPlayer(path); + var actual = SceneManagerHelper.GetExistScenePathOnPlayer(path); Assert.That(actual, Is.EqualTo(SceneName)); } } diff --git a/Tests/Runtime/Utils/ScenePathFinderTest.cs.meta b/Tests/RuntimeInternals/SceneManagerHelperTest.cs.meta similarity index 100% rename from Tests/Runtime/Utils/ScenePathFinderTest.cs.meta rename to Tests/RuntimeInternals/SceneManagerHelperTest.cs.meta From 542a88c497ad6556dc9556c455bcdade976338ab Mon Sep 17 00:00:00 2001 From: Koji Hasegawa Date: Mon, 29 Apr 2024 16:23:12 +0900 Subject: [PATCH 4/6] Mod README.md --- README.md | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 82 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f8f1d67..985f16c 100644 --- a/README.md +++ b/README.md @@ -258,8 +258,50 @@ public class MyTestClass ``` > [!NOTE] -> - Load scene run after `OneTimeSetUp` and before `SetUp` -> - Scene file path is starts with `Assets/` or `Packages/`. And package name using `name` instead of `displayName`, when scenes in the package. (e.g., `Packages/com.nowsprinting.test-helper/Tests/Scenes/Scene.unity`) +> - Load scene run after `OneTimeSetUp` and before `SetUp`. If you want to setup before loading Use [BuildSceneAttribute](#BuildScene) and [SceneManagerHelper](#SceneManagerHelper) method instead. +> - Scene file path is starts with `Assets/` or `Packages/` or `.`. And package name using `name` instead of `displayName`, when scenes in the package. (e.g., `Packages/com.nowsprinting.test-helper/Tests/Scenes/Scene.unity`) + + +#### BuildScene + +`BuildSceneAttribute` is a NUnit test attribute class that build the scene before running the test on player. + +It has the following benefits: + +- Can be specified scenes that are **NOT** in "Scenes in Build". +- Can be specified scene path by [glob](https://en.wikipedia.org/wiki/Glob_(programming)) pattern. However, there are restrictions, top level and scene name cannot be omitted. +- Can be specified scene path by relative path from the test class file. + +This attribute can attached to the test method only. +It can be used with sync Tests, async Tests, and UnityTest. + +Usage: + +```csharp +using NUnit.Framework; +using TestHelper.Attributes; +using TestHelper.RuntimeInternals; +using UnityEngine; + +[TestFixture] +public class MyTestClass +{ + [Test] + [BuildScene("../../Scenes/SampleScene.unity")] + public void MyTestMethod() + { + // Setup before load scene + + // Load scene + await SceneManagerHelper.LoadSceneAsync("../../Scenes/SampleScene.unity"); + + // Excercise the test + } +} +``` + +> [!NOTE] +> - Scene file path is starts with `Assets/` or `Packages/` or `.`. And package name using `name` instead of `displayName`, when scenes in the package. (e.g., `Packages/com.nowsprinting.test-helper/Tests/Scenes/Scene.unity`) #### TakeScreenshot @@ -435,6 +477,44 @@ public class MyTestClass > - UniTask is required to be used from the async method. And also needs coroutineRunner (any MonoBehaviour) because TakeScreenshot method uses WaitForEndOfFrame inside. See more information: https://github.com/Cysharp/UniTask#ienumeratortounitask-limitation +#### SceneManagerHelper + +`SceneManagerHelper` is a utility class to load the scene file. + +It has the following benefits: + +- Can be use same code for running Edit Mode tests, Play Mode tests in Editor, and on Player. +- Can be specified scene path by [glob](https://en.wikipedia.org/wiki/Glob_(programming)) pattern. However, there are restrictions, top level and scene name cannot be omitted. +- Can be specified scene path by relative path from the test class file. + +Usage: + +```csharp +using NUnit.Framework; +using TestHelper.RuntimeInternals; +using UnityEngine; + +[TestFixture] +public class MyTestClass +{ + [Test] + public void MyTestMethod() + { + // Setup before load scene + + // Load scene + await SceneManagerHelper.LoadSceneAsync("../../Scenes/SampleScene.unity"); + + // Excercise the test + } +} +``` + +> [!NOTE] +> - Scene file path is starts with `Assets/` or `Packages/` or `.`. And package name using `name` instead of `displayName`, when scenes in the package. (e.g., `Packages/com.nowsprinting.test-helper/Tests/Scenes/Scene.unity`) +> - When loading the scene that is not in "Scenes in Build", use [BuildSceneAttribute](#BuildScene). + + ### Editor Extensions #### Open Persistent Data Directory From ec446891d83c94afcae582f3e683c601a7df9244 Mon Sep 17 00:00:00 2001 From: Koji Hasegawa Date: Mon, 29 Apr 2024 16:43:20 +0900 Subject: [PATCH 5/6] Fix relative path --- Editor/TemporaryBuildScenesUsingInTest.cs | 2 +- Runtime/Attributes/BuildSceneAttribute.cs | 37 ++----------------- Runtime/Attributes/LoadSceneAttribute.cs | 5 ++- RuntimeInternals/AssemblyInfo.cs | 1 + RuntimeInternals/SceneManagerHelper.cs | 37 +++++++++++++++++-- .../Attributes/BuildSceneAttributeTest.cs | 14 +------ .../SceneManagerHelperTest.cs | 34 ++++++++++------- ...unity => NotInScenesInBuildForBuild.unity} | 0 ... => NotInScenesInBuildForBuild.unity.meta} | 0 9 files changed, 64 insertions(+), 66 deletions(-) rename Tests/Scenes/{NotInScenesInBuildForUse.unity => NotInScenesInBuildForBuild.unity} (100%) rename Tests/Scenes/{NotInScenesInBuildForUse.unity.meta => NotInScenesInBuildForBuild.unity.meta} (100%) diff --git a/Editor/TemporaryBuildScenesUsingInTest.cs b/Editor/TemporaryBuildScenesUsingInTest.cs index 12f7953..39e19a0 100644 --- a/Editor/TemporaryBuildScenesUsingInTest.cs +++ b/Editor/TemporaryBuildScenesUsingInTest.cs @@ -64,7 +64,7 @@ internal static IEnumerable GetScenesUsingInTest() string scenePath; try { - scenePath = SceneManagerHelper.GetExistScenePath(attribute.ScenePath); + scenePath = SceneManagerHelper.GetExistScenePath(attribute.ScenePath, attribute.CallerFilePath); } catch (ArgumentException e) { diff --git a/Runtime/Attributes/BuildSceneAttribute.cs b/Runtime/Attributes/BuildSceneAttribute.cs index f0f38a3..72918a3 100644 --- a/Runtime/Attributes/BuildSceneAttribute.cs +++ b/Runtime/Attributes/BuildSceneAttribute.cs @@ -3,10 +3,8 @@ using System; using System.Diagnostics.CodeAnalysis; -using System.IO; using System.Runtime.CompilerServices; using NUnit.Framework; -using UnityEngine; namespace TestHelper.Attributes { @@ -17,6 +15,7 @@ namespace TestHelper.Attributes public class BuildSceneAttribute : NUnitAttribute { internal string ScenePath { get; private set; } + internal string CallerFilePath { get; private set; } /// /// Build scene before running test on player. @@ -36,38 +35,8 @@ public class BuildSceneAttribute : NUnitAttribute [SuppressMessage("ReSharper", "InvalidXmlDocComment")] public BuildSceneAttribute(string path, [CallerFilePath] string callerFilePath = null) { - if (path.StartsWith(".")) - { - ScenePath = GetAbsolutePath(path, callerFilePath); - } - else - { - ScenePath = path; - } - } - - [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] - internal static string GetAbsolutePath(string relativePath, string callerFilePath) - { - var callerDirectory = Path.GetDirectoryName(callerFilePath); - var absolutePath = Path.GetFullPath(Path.Combine(callerDirectory, relativePath)); - - var assetsIndexOf = absolutePath.IndexOf("Assets", StringComparison.Ordinal); - if (assetsIndexOf > 0) - { - return absolutePath.Substring(assetsIndexOf); - } - - var packageIndexOf = absolutePath.IndexOf("Packages", StringComparison.Ordinal); - if (packageIndexOf > 0) - { - return absolutePath.Substring(packageIndexOf); - } - - Debug.LogError( - $"Can not resolve absolute path. relativePath: {relativePath}, callerFilePath: {callerFilePath}"); - return null; - // Note: Do not use Exception (and Assert). Because freezes async tests on UTF v1.3.4, See UUM-25085. + ScenePath = path; + CallerFilePath = callerFilePath; } } } diff --git a/Runtime/Attributes/LoadSceneAttribute.cs b/Runtime/Attributes/LoadSceneAttribute.cs index b68146c..bf3ec36 100644 --- a/Runtime/Attributes/LoadSceneAttribute.cs +++ b/Runtime/Attributes/LoadSceneAttribute.cs @@ -31,7 +31,7 @@ public class LoadSceneAttribute : BuildSceneAttribute, IOuterUnityTestAction /// (e.g., `Packages/com.nowsprinting.test-helper/Tests/Scenes/Scene.unity`) /// /// - /// - Load scene run after OneTimeSetUp and before SetUp. + /// - Load scene run after OneTimeSetUp and before SetUp. If you want to setup before loading Use and instead. /// - For the process of including a Scene not in "Scenes in Build" to a build for player, see: . /// [SuppressMessage("ReSharper", "ExplicitCallerInfoArgument")] @@ -44,7 +44,8 @@ public LoadSceneAttribute(string path, [CallerFilePath] string callerFilePath = /// public IEnumerator BeforeTest(ITest test) { - yield return SceneManagerHelper.LoadSceneCoroutine(ScenePath); + // ReSharper disable once ExplicitCallerInfoArgument + yield return SceneManagerHelper.LoadSceneCoroutine(ScenePath, CallerFilePath); } /// diff --git a/RuntimeInternals/AssemblyInfo.cs b/RuntimeInternals/AssemblyInfo.cs index c599367..7b15578 100644 --- a/RuntimeInternals/AssemblyInfo.cs +++ b/RuntimeInternals/AssemblyInfo.cs @@ -9,4 +9,5 @@ @"This assembly can be used from the runtime code because it does not depend on test-framework. This assembly is named ""Internal"", however, the included classes are public.")] +[assembly: InternalsVisibleTo("TestHelper.Editor")] [assembly: InternalsVisibleTo("TestHelper.RuntimeInternals.Tests")] diff --git a/RuntimeInternals/SceneManagerHelper.cs b/RuntimeInternals/SceneManagerHelper.cs index b2f47cb..6360f17 100644 --- a/RuntimeInternals/SceneManagerHelper.cs +++ b/RuntimeInternals/SceneManagerHelper.cs @@ -6,6 +6,7 @@ using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; +using System.Runtime.CompilerServices; using System.Text; using System.Text.RegularExpressions; using UnityEngine; @@ -39,9 +40,9 @@ public static class SceneManagerHelper /// When loading the scene that is not in "Scenes in Build", use . /// [SuppressMessage("ReSharper", "InvalidXmlDocComment")] - public static IEnumerator LoadSceneCoroutine(string path) + public static IEnumerator LoadSceneCoroutine(string path, [CallerFilePath] string callerFilePath = null) { - var existScenePath = GetExistScenePath(path); + var existScenePath = GetExistScenePath(path, callerFilePath); AsyncOperation loadSceneAsync = null; if (Application.isEditor) @@ -74,11 +75,17 @@ public static IEnumerator LoadSceneCoroutine(string path) /// Get existing scene file path matches a glob pattern. /// /// Scene file path. Can be specified path by glob pattern. However, there are restrictions, top level and scene name cannot be omitted. + /// CallerFilePath via LoadSceneAttribute, BuildSceneAttribute, and LoadSceneCoroutine. /// Existing scene file path /// Invalid path format /// Scene file not found - public static string GetExistScenePath(string path) + internal static string GetExistScenePath(string path, string callerFilePath) { + if (path.StartsWith(".")) + { + path = GetAbsolutePath(path, callerFilePath); + } + ValidatePath(path); #if UNITY_EDITOR return GetExistScenePathInEditor(path); @@ -87,6 +94,30 @@ public static string GetExistScenePath(string path) #endif } + internal static string GetAbsolutePath(string relativePath, string callerFilePath) + { + var callerDirectory = Path.GetDirectoryName(callerFilePath); + // ReSharper disable once AssignNullToNotNullAttribute + var absolutePath = Path.GetFullPath(Path.Combine(callerDirectory, relativePath)); + + var assetsIndexOf = absolutePath.IndexOf("Assets", StringComparison.Ordinal); + if (assetsIndexOf > 0) + { + return absolutePath.Substring(assetsIndexOf); + } + + var packageIndexOf = absolutePath.IndexOf("Packages", StringComparison.Ordinal); + if (packageIndexOf > 0) + { + return absolutePath.Substring(packageIndexOf); + } + + Debug.LogError( + $"Can not resolve absolute path. relativePath: {relativePath}, callerFilePath: {callerFilePath}"); + return null; + // Note: Do not use Exception (and Assert). Because freezes async tests on UTF v1.3.4, See UUM-25085. + } + private static void ValidatePath(string path) { if (!path.StartsWith("Assets/") && !path.StartsWith("Packages/")) diff --git a/Tests/Runtime/Attributes/BuildSceneAttributeTest.cs b/Tests/Runtime/Attributes/BuildSceneAttributeTest.cs index 5e7aa68..8c67b07 100644 --- a/Tests/Runtime/Attributes/BuildSceneAttributeTest.cs +++ b/Tests/Runtime/Attributes/BuildSceneAttributeTest.cs @@ -13,7 +13,7 @@ namespace TestHelper.Attributes [TestFixture] public class BuildSceneAttributeTest { - private const string TestScene = "../../Scenes/NotInScenesInBuildForUse.unity"; + private const string TestScene = "../../Scenes/NotInScenesInBuildForBuild.unity"; private const string ObjectName = "CubeInNotInScenesInBuild"; [Test] @@ -27,17 +27,5 @@ public async Task Attach_SceneIntoBuild() cube = GameObject.Find(ObjectName); Assume.That(cube, Is.Not.Null); } - - [TestCase("./Scene.unity", // include `./` - "Assets/Tests/Runtime/Caller.cs", - "Assets/Tests/Runtime/Scene.unity")] - [TestCase("../../BadPath/../Scenes/Scene.unity", // include `../` - "Packages/com.nowsprinting.test-helper/Tests/Runtime/Attributes/Caller.cs", - "Packages/com.nowsprinting.test-helper/Tests/Scenes/Scene.unity")] - public void GetAbsolutePath(string relativePath, string callerFilePath, string expected) - { - var actual = BuildSceneAttribute.GetAbsolutePath(relativePath, callerFilePath); - Assert.That(actual, Is.EqualTo(expected)); - } } } diff --git a/Tests/RuntimeInternals/SceneManagerHelperTest.cs b/Tests/RuntimeInternals/SceneManagerHelperTest.cs index 70590dd..44167e7 100644 --- a/Tests/RuntimeInternals/SceneManagerHelperTest.cs +++ b/Tests/RuntimeInternals/SceneManagerHelperTest.cs @@ -14,22 +14,30 @@ namespace TestHelper.RuntimeInternals [TestFixture] public class SceneManagerHelperTest { - [Test] + [TestCase("Packages/com.nowsprinting.test-helper/Tests/Scenes/NotInScenesInBuild.unity")] + [TestCase("Packages/com.nowsprinting.test-helper/**/NotInScenesInBuildForGlob.unity")] + [TestCase("../Scenes/NotInScenesInBuildForRelative.unity")] [UnityPlatform(RuntimePlatform.OSXEditor, RuntimePlatform.WindowsEditor, RuntimePlatform.LinuxEditor)] // Note: Tests to run on the player, see `BuildSceneAttributeTest` - public async Task LoadSceneCoroutine_LoadedScene() + public async Task LoadSceneCoroutine_LoadedScene(string path) { - const string TestScene = "../Scenes/NotInScenesInBuildForUse.unity"; - const string ObjectName = "CubeInNotInScenesInBuild"; - - var cube = GameObject.Find(ObjectName); - Assume.That(cube, Is.Null, "Not loaded "); - - await SceneManagerHelper.LoadSceneCoroutine(TestScene); - cube = GameObject.Find(ObjectName); + await SceneManagerHelper.LoadSceneCoroutine(path); + var cube = GameObject.Find("CubeInNotInScenesInBuild"); Assume.That(cube, Is.Not.Null); } + [TestCase("./Scene.unity", // include `./` + "Assets/Tests/Runtime/Caller.cs", + "Assets/Tests/Runtime/Scene.unity")] + [TestCase("../../BadPath/../Scenes/Scene.unity", // include `../` + "Packages/com.nowsprinting.test-helper/Tests/Runtime/Attributes/Caller.cs", + "Packages/com.nowsprinting.test-helper/Tests/Scenes/Scene.unity")] + public void GetAbsolutePath(string relativePath, string callerFilePath, string expected) + { + var actual = SceneManagerHelper.GetAbsolutePath(relativePath, callerFilePath); + Assert.That(actual, Is.EqualTo(expected)); + } + [TestCase("Packages/com.nowsprinting.test-helper/Tests/Scenes/NotInScenesInBuild.unity")] [TestCase("Packages/com.nowsprinting.test-helper/Tes?s/S?enes/NotInScenesInBuild.unity")] [TestCase("Packages/com.nowsprinting.test-helper/*/*/NotInScenesInBuild.unity")] @@ -42,7 +50,7 @@ public void GetExistScenePath_ExistPath_GotExistScenePath(string path) const string ExistScenePath = "NotInScenesInBuild"; // Scene name only #endif - var actual = SceneManagerHelper.GetExistScenePath(path); + var actual = SceneManagerHelper.GetExistScenePath(path, null); Assert.That(actual, Is.EqualTo(ExistScenePath)); } @@ -53,7 +61,7 @@ public void GetExistScenePath_ExistPath_GotExistScenePath(string path) [TestCase("Packages/com.nowsprinting.test-helper/Tests/Scenes/*InScenesInBuild.unity")] public void GetExistScenePath_InvalidGlobPattern_ThrowsArgumentException(string path) { - Assert.That(() => SceneManagerHelper.GetExistScenePath(path), Throws.TypeOf()); + Assert.That(() => SceneManagerHelper.GetExistScenePath(path, null), Throws.TypeOf()); } [TestCase("Packages/com.nowsprinting.test-helper/Tests/Scenes/NotExistScene.unity")] // Not exist path @@ -61,7 +69,7 @@ public void GetExistScenePath_InvalidGlobPattern_ThrowsArgumentException(string [UnityPlatform(RuntimePlatform.OSXEditor, RuntimePlatform.WindowsEditor, RuntimePlatform.LinuxEditor)] public void GetExistScenePath_NotExistPath_InEditor_ThrowsFileNotFoundException(string path) { - Assert.That(() => SceneManagerHelper.GetExistScenePath(path), Throws.TypeOf()); + Assert.That(() => SceneManagerHelper.GetExistScenePath(path, null), Throws.TypeOf()); // Note: Returns scene name when running on player. } diff --git a/Tests/Scenes/NotInScenesInBuildForUse.unity b/Tests/Scenes/NotInScenesInBuildForBuild.unity similarity index 100% rename from Tests/Scenes/NotInScenesInBuildForUse.unity rename to Tests/Scenes/NotInScenesInBuildForBuild.unity diff --git a/Tests/Scenes/NotInScenesInBuildForUse.unity.meta b/Tests/Scenes/NotInScenesInBuildForBuild.unity.meta similarity index 100% rename from Tests/Scenes/NotInScenesInBuildForUse.unity.meta rename to Tests/Scenes/NotInScenesInBuildForBuild.unity.meta From 064edf74134059804b85acc8022ba33f161a6b78 Mon Sep 17 00:00:00 2001 From: Koji Hasegawa Date: Mon, 29 Apr 2024 18:06:04 +0900 Subject: [PATCH 6/6] Rename LoadSceneCoroutine to LoadSceneAsync --- Runtime/Attributes/LoadSceneAttribute.cs | 4 ++-- RuntimeInternals/SceneManagerHelper.cs | 4 ++-- Tests/Runtime/Attributes/BuildSceneAttributeTest.cs | 2 +- Tests/RuntimeInternals/SceneManagerHelperTest.cs | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Runtime/Attributes/LoadSceneAttribute.cs b/Runtime/Attributes/LoadSceneAttribute.cs index bf3ec36..6dbbbd6 100644 --- a/Runtime/Attributes/LoadSceneAttribute.cs +++ b/Runtime/Attributes/LoadSceneAttribute.cs @@ -31,7 +31,7 @@ public class LoadSceneAttribute : BuildSceneAttribute, IOuterUnityTestAction /// (e.g., `Packages/com.nowsprinting.test-helper/Tests/Scenes/Scene.unity`) /// /// - /// - Load scene run after OneTimeSetUp and before SetUp. If you want to setup before loading Use and instead. + /// - Load scene run after OneTimeSetUp and before SetUp. If you want to setup before loading Use and instead. /// - For the process of including a Scene not in "Scenes in Build" to a build for player, see: . /// [SuppressMessage("ReSharper", "ExplicitCallerInfoArgument")] @@ -45,7 +45,7 @@ public LoadSceneAttribute(string path, [CallerFilePath] string callerFilePath = public IEnumerator BeforeTest(ITest test) { // ReSharper disable once ExplicitCallerInfoArgument - yield return SceneManagerHelper.LoadSceneCoroutine(ScenePath, CallerFilePath); + yield return SceneManagerHelper.LoadSceneAsync(ScenePath, CallerFilePath); } /// diff --git a/RuntimeInternals/SceneManagerHelper.cs b/RuntimeInternals/SceneManagerHelper.cs index 6360f17..6b07d45 100644 --- a/RuntimeInternals/SceneManagerHelper.cs +++ b/RuntimeInternals/SceneManagerHelper.cs @@ -40,7 +40,7 @@ public static class SceneManagerHelper /// When loading the scene that is not in "Scenes in Build", use . /// [SuppressMessage("ReSharper", "InvalidXmlDocComment")] - public static IEnumerator LoadSceneCoroutine(string path, [CallerFilePath] string callerFilePath = null) + public static IEnumerator LoadSceneAsync(string path, [CallerFilePath] string callerFilePath = null) { var existScenePath = GetExistScenePath(path, callerFilePath); AsyncOperation loadSceneAsync = null; @@ -75,7 +75,7 @@ public static IEnumerator LoadSceneCoroutine(string path, [CallerFilePath] strin /// Get existing scene file path matches a glob pattern. /// /// Scene file path. Can be specified path by glob pattern. However, there are restrictions, top level and scene name cannot be omitted. - /// CallerFilePath via LoadSceneAttribute, BuildSceneAttribute, and LoadSceneCoroutine. + /// CallerFilePath via LoadSceneAttribute, BuildSceneAttribute, and LoadSceneAsync. /// Existing scene file path /// Invalid path format /// Scene file not found diff --git a/Tests/Runtime/Attributes/BuildSceneAttributeTest.cs b/Tests/Runtime/Attributes/BuildSceneAttributeTest.cs index 8c67b07..bc96892 100644 --- a/Tests/Runtime/Attributes/BuildSceneAttributeTest.cs +++ b/Tests/Runtime/Attributes/BuildSceneAttributeTest.cs @@ -23,7 +23,7 @@ public async Task Attach_SceneIntoBuild() var cube = GameObject.Find(ObjectName); Assume.That(cube, Is.Null, "Not loaded "); - await SceneManagerHelper.LoadSceneCoroutine(TestScene); // Can also be loaded by running the player + await SceneManagerHelper.LoadSceneAsync(TestScene); // Can also be loaded by running the player cube = GameObject.Find(ObjectName); Assume.That(cube, Is.Not.Null); } diff --git a/Tests/RuntimeInternals/SceneManagerHelperTest.cs b/Tests/RuntimeInternals/SceneManagerHelperTest.cs index 44167e7..d1620a3 100644 --- a/Tests/RuntimeInternals/SceneManagerHelperTest.cs +++ b/Tests/RuntimeInternals/SceneManagerHelperTest.cs @@ -19,9 +19,9 @@ public class SceneManagerHelperTest [TestCase("../Scenes/NotInScenesInBuildForRelative.unity")] [UnityPlatform(RuntimePlatform.OSXEditor, RuntimePlatform.WindowsEditor, RuntimePlatform.LinuxEditor)] // Note: Tests to run on the player, see `BuildSceneAttributeTest` - public async Task LoadSceneCoroutine_LoadedScene(string path) + public async Task LoadSceneAsync_LoadedScene(string path) { - await SceneManagerHelper.LoadSceneCoroutine(path); + await SceneManagerHelper.LoadSceneAsync(path); var cube = GameObject.Find("CubeInNotInScenesInBuild"); Assume.That(cube, Is.Not.Null); }