"Object reference not set to an instance of an object" but it is.

Code its self pretty basic issue is once i bake one bundle any other GMC can not be baked pops up error of
_
NullReferenceException: Object reference not set to an instance of an object
BuildMod.OnGUI () (at Assets/Editor/BuildMod.cs:32)
_
Here is code I’m working with few friends on this as well if i figure out ill post my findings
_

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class BuildMod : EditorWindow
{
    GMC GMC_Data;

    [MenuItem("Assets/Cook Mod")]
    static void BuildAllAssetBundles()
    {
        EditorWindow.GetWindow(typeof(BuildMod));
    }

    void ClearData()
    {       
        AssetDatabase.RemoveUnusedAssetBundleNames();
        EditorWindow.GetWindow(typeof(BuildMod)).Close();
    }

    private void OnGUI()
    {
        GMC_Data = EditorGUILayout.ObjectField(GMC_Data, typeof(GMC), true) as GMC;

        if (GMC_Data != null)
        {
            if (GUILayout.Button("Cook"))
            {
                AssetImporter.GetAtPath("Assets/Mods/" + GMC_Data.Name + "/" + GMC_Data.Name + ".asset").SetAssetBundleNameAndVariant(GMC_Data.Name, "GMC");                
                BuildPipeline.BuildAssetBundles("Assets/StreamingAssets/" + GMC_Data.name, BuildAssetBundleOptions.UncompressedAssetBundle, BuildTarget.StandaloneWindows64);
                AssetImporter.GetAtPath("Assets/Mods/" + GMC_Data.Name + "/" + GMC_Data.Name + ".asset").SetAssetBundleNameAndVariant("", "");
                ClearData();
            }           
        }
    }
}

Perhaps putting GMC_Data = EditorGUILayout.ObjectField(GMC_Data, typeof(GMC), true) as GMC; inside of the Start function instead of OnGUI function would work? I’m guessing the error is coming from that line of code I recommended to put in start since the other lines do a if not null check. I’m not really familiar with GUI but figured it wouldn’t hurt trying to help.

I was able figure it out I was using variable GMC.Name instead of GMC.name which is name of the asset by replace Name with name the issue has been fixed and now works everytime without issue.