- Home /
The question is answered, right answer was accepted
Find ALL game objects containing the same scrip
Hi,
Is it possible to find ALL game objects containing the same script in my project, or does anyone know of a pug in ?
The reason I ask is over the years if created so many scripts and I'm sure some of them now are not needed or used by any game object so would like to delete them because I'm on a quest to clean up my project.
Thanks.
Answer by GameVortex · Sep 30, 2014 at 08:26 AM
Then there is this: http://answers.unity3d.com/questions/223434/find-all-assets-by-type.html
Answer by GameVortex · Sep 30, 2014 at 07:59 AM
You can use the Static function FindObjectsOfType from the class Object. This finds only objects in the Scene basically, or did you want a way to find prefabs which use the script as well?
Thanks for the reply, I'm looking to search through my project, scene, Asset folder and it's hierarchy, my project not just my scene as I might have a game object in a folder using the script but not yet placed in the scene.
Thats what I needed, thank you, please convert your comment to an answer so I can except it.
Answer by Kiwasi · Sep 30, 2014 at 08:36 AM
There is another method.
Back up your project. Delete the scripts. See what breaks.
Not saying its a good solution.
Actually now that I think of it you could put a Debug.Log in Awake that provides you with a pointer to the object. Its not a bullet proof solution by any means, but it will tell you if any GameObjects currently in use need the script.
rename the file (& the defined class if it's c#) and look for compile/runtime errors
Yeah but I'm looking to search through my project, scene, Asset folder and it's hierarchy, my project not just my scene as I might have a game object in a folder using the script but not yet placed in the scene.
Think GameVortex link above is the answer ..