Hello all,
when I open my scene, I get this error:
The referenced script (Unknown) on this Behavior is missing!
When I click on it, it doesn’t show me, which GameObject it is referring to. As I have a lot of GameObjects in the scene, it would take me forever to go through it manually.
So I would like to write a script, which goes through all GameObjects and returns the ones with ANY Script attached. Unfortunately there seems to be no such a general script-component. So how do I do it?
This is how my script would look like in an ideal world:
GameObject[] allObjects = FindObjectsOfType<GameObject>();
foreach (Object obj in allObjects)
if (GameObject.FindObjectsOfType<Script>)
{
Debug.Log(object.name);
}
But this is not possible, so how can I do it correctly?
Thank you
Huxi
Simple, use tag to every game object you wanted to be in list and then call Game object find object with tag will get all in one place or there is 100s of way to do it. Let me know if that helps.
– Mohammed-RehmanJust to make sure that I got it correctly, is your proposal to go to each GameObject and set a tag on it? As I mentioned, I have a lot of GOs.
– Huxii