public void SetUp() { m_TempAssets.SetUp(); m_SubSceneTest.Setup(); m_World.Setup(); DefaultWorldInitialization.DefaultLazyEditModeInitialize(); m_Texture1 = new Texture2D(64, 64); AssetDatabase.CreateAsset(m_Texture1, m_TempAssets.GetNextPath("Texture1.asset")); m_Texture2 = new Texture2D(32, 32); AssetDatabase.CreateAsset(m_Texture2, m_TempAssets.GetNextPath("Texture2.asset")); }
public void SetUp() { if (m_Assets.TempAssetDir != null) { // this setup code is run again when we switch to playmode return; } // Create a temporary folder for test assets m_Assets.SetUp(); m_DefaultWorld.Setup(); m_WasLiveLinkEnabled = SubSceneInspectorUtility.LiveLinkEnabledInEditMode; m_EnterPlayModeOptions = EditorSettings.enterPlayModeOptions; m_UseEnterPlayerModeOptions = EditorSettings.enterPlayModeOptionsEnabled; SubSceneInspectorUtility.LiveLinkEnabledInEditMode = true; AssetDatabase.CreateAsset(m_TestTexture = new Texture2D(64, 64), m_Assets.GetNextPath(".asset")); AssetDatabase.CreateAsset(m_TestMaterial = new Material(Shader.Find("Standard")), m_Assets.GetNextPath(".mat")); m_TestMaterial.mainTexture = m_TestTexture; }
public static void SetUpOnce() { s_Assets.SetUp(); var assetGuids = new List <GUID>(); try { { string path = s_Assets.GetNextPath(".asset"); AssetDatabase.CreateAsset(s_TempTexture = new Texture2D(64, 64), path); s_TempTextureGuid = new GUID(AssetDatabase.AssetPathToGUID(path)); assetGuids.Add(s_TempTextureGuid); } { string path = s_Assets.GetNextPath(".mat"); AssetDatabase.CreateAsset(s_TempMaterial = new Material(Shader.Find("Standard")), path); s_TempMaterialGuid = new GUID(AssetDatabase.AssetPathToGUID(path)); assetGuids.Add(s_TempMaterialGuid); s_TempMaterial.mainTexture = s_TempTexture; } var tempScenePath = s_Assets.GetNextPath(".unity"); s_TempScene = SubSceneTestsHelper.CreateScene(tempScenePath); s_SubSceneWithSections = SubSceneTestsHelper.CreateSubSceneInSceneFromObjects("SubScene", false, s_TempScene, () => { var go1 = new GameObject(); go1.AddComponent <SceneSectionComponent>().SectionIndex = 0; var go2 = new GameObject(); go2.AddComponent <SceneSectionComponent>().SectionIndex = 2; go2.AddComponent <TestComponentAuthoring>().Material = s_TempMaterial; return(new List <GameObject> { go1, go2 }); }); { var path = s_Assets.GetNextPath("LiveLinkBuildConfig.buildconfiguration"); BuildConfiguration.CreateAsset(path, config => { config.SetComponent(new SceneList { SceneInfos = new List <SceneList.SceneInfo> { new SceneList.SceneInfo { Scene = GlobalObjectId.GetGlobalObjectIdSlow(AssetDatabase.LoadAssetAtPath <SceneAsset>(tempScenePath)) } } }); }); s_LiveLinkBuildConfigGuid = new GUID(AssetDatabase.AssetPathToGUID(path)); } } catch { s_Assets.TearDown(); throw; } // This call ensures that the asset worker is already running and no test times out because we're still // waiting for the asset worker. Effectively this doesn't change the runtime that much since we will have // to wait for the import to finish in most of the tests anyway. GetLiveLinkArtifactHash(s_TempMaterialGuid, ImportMode.Synchronous); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); s_TempAssetGuids = assetGuids.ToArray(); }
Scene CreateTmpScene() => SubSceneTestsHelper.CreateScene(m_Assets.GetNextPath() + ".unity");
public static Scene CreateTmpScene(ref TestWithTempAssets testAssets) { var parentScenePath = testAssets.GetNextPath() + ".unity"; return(CreateScene(parentScenePath)); }