The Component class has getters for most of the built-in components. Quite literally:
public class Component : Object {
public Transform transform {
get { return GetComponent(); }
}
// etc
}
Note, that `MonoBehaviour` is a class inside of the `UnityEngine`. `MonoBehaviour` inherits from `Components`. So to answer your question, it's both because of `MonoBehaviour`, `UnityEngine` *as well as* `Component`.
Also note, that `GetComponent` is actually an alias for `gameObject.GetComponent`. A bunch of functions are like this and exist purely to make things a little bit easier.
Trending Articles
More Pages to Explore .....