Where do components get added in Unity?

In unity's GameObject class, there are a few default data members. When we add a component to the game object, light for example, where exactly does it get added? Does it become a part of the GameObject class?

Answers 1

In the past, components used to be added to the GameObject itself, in such a way, that you could call myGameObject.renderer to get an object's Renderer.

This however changed to the call of myGameObject.GetComponent<Renderer>(), which hides the details of where the components are saved, which shouldn't be relevant anyway. Since for most (if not all) cases it doesn't matter for the user where components are, but that they belong to an object.