I’d like to get a list (or array) of all Object(s) attached to a GameObject to determine if any non-MonoBehaviour scripts are attached. They could be of any custom class so GetComponentsInChildren() will not work.
Essentially I’m trying to delete GameObjects that only have a Transform but no other scripts or components attached.
That will get you every single component, active or inactive, for the entire GameObject including itself. Then you’ll have to loop through and build your own table of what is attached to what.
Yep, as I said above, I need to get non-Monobehaviour scripts too (which GetComponentsInChildren doesn’t do). So thanks for your response but unfortunately that doesn’t work.
Update: Didn’t try so will give that a try.
GetComponents Or GetComponentsInChildren will get all Conponents. That includes MonoBehaviours, and the built ins that inherit straight from Component.
You can’t actually attatch any other type of script to a GameObject. So where is the problem?
Only Components can be attached to a GameObject; these are the things that appear in the inspector for that object. You can also have other GameObjects be children of a parent GameObject; these are the things that appear underneath the GameObject in the hierarchy. If you’re trying to get the children GameObjects, it’s: