I have a GameObject
in Unity that is supposed to serve as a container for some definitions.
I'd like to access that object and retrieve the Def
class instances (every object there is instance of Def
general class).
So, if I have a GameObject
instance, how can I retrieve all objects that are instances of specific class?
You can use the GameObject.GetComponents<Def>();
to retrieve all components of Def
type in the GameObject
.
More info in the Unity Docs http://docs.unity3d.com/ScriptReference/GameObject.GetComponents.html