My problem got solved. I will put points toward Leggy7 as he gave me the idea to solve my the problem.
The Old procedure is his way of solving it....
List<GameObject> FindSceneObjects_Old(String sceneName)
{
List<GameObject> objs = new List<GameObject>();
foreach (GameObject obj in GameObject.FindObjectsOfType(typeof(GameObject)))
{
if (obj.scene.name == sceneName)
{
objs.Add(obj);
}
}
return objs;
}
This is my way of solving it using LINQ
List<GameObject> FindSceneObjects(String sceneName)
{
var objs = from GameObject go in GameObject.FindObjectsOfType(typeof(GameObject)) where go.scene.name == sceneName select go;
return objs.ToList();
}
I am aware there is a shorthand for writing LINQ statements but since I have a Background in SQL I am used to this format.