Accessing a static var from Custom Editor

Hi,

I was checking some posts about viewing static vars from a Custom Editor but in my case I just need to pull data from a static var I have in a MonoBehaviour class. What I have is this:

MonoBehaviour Class with static var

using UnityEngine;
using System.Collections.Generic;

public class GameData : MonoBehaviour {

public static int score;
}

then in my custom editor class

using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
 
[CustomEditor(typeof(SpriteGUIController))]
public class SpriteGUIEditorController: Editor
{
	public override void OnInspectorGUI()
        {
           score= GameData.score;
        }
}

The error I am getting is this: NullReferenceException: Object reference not set to an instance of an object

Any idea what I am doing wrong?

Thanks in advance

Learner

I am almost sure that the error is produced at another place, because what you are showing is trivial and there is no reason why line 10 in the second script should produce a NullReferenceException.

As a side note: It is not necessary that GameData inherits MonoBehaviour.