How come extension methods for Component are not shown in Mono’s Intellisense when used in a MonoBehaviour script?
In a MonoBehaviour script, you can call directly GetComponent (), since MonoBehaviour inherits from Component, but you can’t do that with an extension method. You have to specify the “this” reference.
Example :
public static class ComponentExtensions {
public static void DebugName (this Component c) {
Debug.Log(c.name);
}
}
public class MyClass : MonoBehaviour {
void Start () {
DebugName (); // Does not compile!!
this.DebugName () // Works as intended
}
}
Is this the intended behaviour ?