Why is GetComponent() causing a null exception

This line in my code

GetComponent<EditorGUI>().bMouseOverGUI = false;

and every other GetComponent() call I do causisi this runtime error :
NullReferenceException: Object reference not set to an instance of an object.

Does anyone know why this happens? Thanks.

Do you actually have a script called EditorGUI? If so, you shouldn’t call it that, since it’s the name of one of Unity’s classes.

The problem was that I was calling the script during Start(). Thanks!