Hello, I am trying to make a test to check if an particular object is in all scenes in my project, in this case the object is Transition.
However the current snippet won’t iterate throw all scenes.
I tried with SceneManager.sceneCount also but nothing. How can I do it?
[Test]
public void ObjectInAllScenes()
{
var rootObjects = new List<GameObject>();
for (int j = 0; j < SceneManager.sceneCountInBuildSettings; j++)
{
var isIn = false;
var scene = SceneManager.GetSceneAt(j);
scene.GetRootGameObjects(rootObjects);
for (int i = 0; i < rootObjects.Count && !isIn; ++i)
{
if (rootObjects[i].name == "Transition")
{
isIn = true;
}
}
if (!isIn)
{
Assert.Fail("Fail: " + scene.name);
}
}
Assert.Pass();
}