How does iTween extend the GameObject class?


I saw this extension for iTween:

And I wonder how did they go about adding new functions in the GameObject class?

This is how I would add new functions to a class: (Theoretically, I haven’t tested it with MonoBehaviour)

public class MyMonoBehaviour : MonoBehaviour

MyMonoBehaviour inherits MonoBehaviour and all of its functions, you could then add functions into MyMonoBehaviour extending MonoBehaviour, but do be sure that all of your scripts (that would normally inherit MonoBehaviour) is changed to inherit MyMonoBehaviour so you get all the functions you added.

It is done using a C# Extension method. They allow you to add additional functionality to a class without directly modifying or accessing that class.