|
|
|
|
|
|
using UnityEngine.SceneManagement; |
|
|
|
using UnityEngine.Events; |
|
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
using UnityEditor; |
|
|
|
using EditorSceneManagement = UnityEditor.SceneManagement; |
|
|
|
#endif
|
|
|
|
|
|
|
|
public class HDRP_GraphicTestRunner : IPrebuildSetup |
|
|
|
public class HDRP_GraphicTestRunner |
|
|
|
{ |
|
|
|
[UnityTest, Category("HDRP Graphic Tests")] |
|
|
|
[PrebuildSetup("SetupGraphicsTestCases")] |
|
|
|
|
|
|
yield return null; |
|
|
|
|
|
|
|
ImageAssert.AreEqual(testCase.ReferenceImage, camera, (settings != null)?settings.ImageComparisonSettings:null); |
|
|
|
} |
|
|
|
|
|
|
|
public void Setup() |
|
|
|
{ |
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
|
|
|
// Search for "InitTestSceneXXXXXXXX" generated by test runner and save the path in the EditorPrefs
|
|
|
|
for (int i=0 ; i<EditorSceneManagement.EditorSceneManager.sceneCount ; ++i) |
|
|
|
{ |
|
|
|
Scene scene = EditorSceneManagement.EditorSceneManager.GetSceneAt(i); |
|
|
|
if (scene.name.StartsWith("InitTestScene")) |
|
|
|
{ |
|
|
|
EditorPrefs.SetString("InitTestScene", scene.path); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
string scenesWithAutoLightMap = ""; |
|
|
|
|
|
|
|
// For each scene in the build settings, force build of the lightmaps if it has "DoLightmap" label.
|
|
|
|
foreach( EditorBuildSettingsScene scene in EditorBuildSettings.scenes) |
|
|
|
{ |
|
|
|
SceneAsset sceneAsset = AssetDatabase.LoadAssetAtPath<SceneAsset>(scene.path); |
|
|
|
var labels = new System.Collections.Generic.List<string>(AssetDatabase.GetLabels(sceneAsset)); |
|
|
|
|
|
|
|
if ( labels.Contains("DoLightmap") ) |
|
|
|
{ |
|
|
|
EditorSceneManagement.EditorSceneManager.OpenScene(scene.path, EditorSceneManagement.OpenSceneMode.Single); |
|
|
|
|
|
|
|
Lightmapping.giWorkflowMode = Lightmapping.GIWorkflowMode.OnDemand; |
|
|
|
EditorSceneManagement.EditorSceneManager.SaveOpenScenes(); |
|
|
|
|
|
|
|
Lightmapping.Clear(); |
|
|
|
Lightmapping.Bake(); |
|
|
|
|
|
|
|
scenesWithAutoLightMap += scene.path + ";"; |
|
|
|
|
|
|
|
EditorSceneManagement.EditorSceneManager.SaveOpenScenes(); |
|
|
|
|
|
|
|
Lightmapping.giWorkflowMode = Lightmapping.GIWorkflowMode.Iterative; |
|
|
|
EditorSceneManagement.EditorSceneManager.SaveOpenScenes(); |
|
|
|
|
|
|
|
EditorSceneManagement.EditorSceneManager.NewScene(EditorSceneManagement.NewSceneSetup.EmptyScene); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
EditorPrefs.SetString("ScenesWithAutoLightMap", scenesWithAutoLightMap); |
|
|
|
|
|
|
|
// Re-open testrunner scene
|
|
|
|
string initTestSceneString = EditorPrefs.GetString("InitTestScene"); |
|
|
|
if (!string.IsNullOrEmpty(initTestSceneString)) |
|
|
|
{ |
|
|
|
EditorSceneManagement.EditorSceneManager.OpenScene(initTestSceneString, EditorSceneManagement.OpenSceneMode.Single); |
|
|
|
} |
|
|
|
#endif
|
|
|
|
} |
|
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|