- Home /
List objects in a scene file
I want to do this at runtime, I want to generate a list of gameobjects in a scene file without loading the scene file for the player.
As an example, I have "Level One" scene file, and I want to list all the "NPC" objects that are in that scene and display a list of those npcs in my current scene.
My guess as to how to accomplish this would be to "pre load" the scene then search it somehow with GameObject.Find().
Does anyone know if there is a better way to generate this kind of list?
Thanks
I would suggest extracting this data from the scene and save it somewhere else. For example, reference all NPCs in a list on a scriptable object.
You then only need to be concerned about keeping the data up-to-date if you add or remove a NPC from the scene. Perhaps use Asset$$anonymous$$odificationProcessor.OnWillSaveAssets to automatically keep it updated.