Hi all!
I’m having a problem reading a Unity scene “as a GameObject”. The testing script should test the scene’s contents, this is what I have so far:
private static SceneAsset LoadScene(string path)
{
return (SceneAsset)AssetDatabase.LoadAssetAtPath(path, typeof(SceneAsset));
}
private static void ValidateScenes()
{
foreach (string s in Directory.GetFiles("Assets/", "*.unity", SearchOption.AllDirectories))
{
foreach(Transform transform in LoadScene(s).FindObjectsOfType<Transform>())
{
ValidateRecoursive(transform);
}
}
}
But while this approach works fine for GameObjects (prefabs) and ScriptableObjects (assets) - I couldn’t get it working for a Scene (as FindObjectsOfType is static in the code above, I also tried several other approaches). It feels like I’m missing something obvious here.
TL;DR: What I need to do is to get access to all Transforms inside of a Scene file.