unity3d Finding and collecting GameObjects Finding GameObjects by MonoBehaviour scripts


Example

ExampleScript script = GameObject.FindObjectOfType<ExampleScript>();
GameObject go = script.gameObject;

FindObjectOfType() returns null if none is found.

ProsCons
Strongly typedPerformance degrades along the number of gameobjects needed to evaluate
Possible to search both single objects and entire groups