public static bool CanEditScene(SubScene subScene) { if (!subScene.CanBeLoaded()) return false; return !subScene.IsLoaded; }
public IEnumerator TestSetup_ProducesExpectedResult() { // Initial setup is clean and all is as expected Assert.That(m_SubScene.name, Is.EqualTo(k_SubSceneName)); Assert.That(m_SubScene.SceneName, Is.EqualTo(k_SubSceneName)); Assert.That(m_SubScene.CanBeLoaded(), Is.True); Assert.That(m_SubScene.IsLoaded, Is.True); Assert.That(m_SubScene.EditingScene.isLoaded, Is.True); Assert.That(m_SubScene.EditingScene.isSubScene, Is.True); Assert.That(m_SubSceneRoot.name, Is.EqualTo(k_SubSceneName)); Assert.That(m_SubSceneRoot, Is.EqualTo(m_SubScene.gameObject)); Assert.That(m_SubSceneRoot.GetComponent <SubScene>(), Is.Not.Null); Assert.That(m_SubSceneRoot.transform.childCount, Is.EqualTo(0)); Assert.That(m_Scene.rootCount, Is.EqualTo(1)); Assert.That(m_SubScene.EditingScene.rootCount, Is.EqualTo(0)); // Adding a GameObject to a SubScene var go = new GameObject("go"); SceneManager.MoveGameObjectToScene(go, m_SubScene.EditingScene); Assert.That(m_SubScene.EditingScene.rootCount, Is.EqualTo(1)); Assert.That(m_SubScene.EditingScene.GetRootGameObjects()[0], Is.EqualTo(go)); Assert.That(go.scene, Is.EqualTo(m_SubScene.EditingScene)); // Parenting into a SubScene var childGO = new GameObject("childGO"); Assert.That(childGO.scene, Is.EqualTo(m_Scene)); childGO.transform.parent = go.transform; Assert.That(childGO.scene, Is.EqualTo(m_SubScene.EditingScene)); // Expected Entities: 1. WorldTime - 2. SubScene - 3. SceneSection Assert.That(m_Manager.UniversalQuery.CalculateEntityCount(), Is.EqualTo(3)); yield return(UpdateLiveLink()); Assert.That(m_Window.World, Is.EqualTo(World.DefaultGameObjectInjectionWorld)); // Expected Entities: 1. WorldTime - 2. SubScene - 3. SceneSection - 4. Converted `go` - 5. Converted `childGO` Assert.That(m_Manager.UniversalQuery.CalculateEntityCount(), Is.EqualTo(5)); // TearDown properly cleans-up the SubScene TearDownSubScene(); Assert.That(m_SubScene.EditingScene.rootCount, Is.EqualTo(0)); yield return(UpdateLiveLink()); // Expected Entities: 1. WorldTime - 2. SubScene - 3. SceneSection Assert.That(m_Manager.UniversalQuery.CalculateEntityCount(), Is.EqualTo(3)); }