NullReferenceException (655548)

So i cant for the life of me figure out the issue

heres the error im getting
Error in console

NullReferenceException: Object reference not set to an instance of an object
GameController.UpdateInfo () (at Assets/newScripting/GameController.cs:265)
GameController.Update () (at Assets/newScripting/GameController.cs:174)

here is the line of code the error is pertaining to

UpgradeManager.Instance.AddButton ("Upgrade Keyboard\n$" + keyboardCost, keyboardCost, "proKeyboard");

and here is the function thats being called
function being called

public void AddButton(string text,int cost,string type){
        Button[] buttons = this.GetComponentsInChildren<Button> (true);
        foreach (Button but in buttons) {
            if (but.GetComponent<ButtonInfo> ().buttonType == type) {
                return;
            }
        }
        GameObject b = Instantiate (buttonPrefab, new Vector3 (20, -bc * 50, 0), buttonPrefab.transform.rotation) as GameObject;
        b.transform.SetParent (transform, false);
        b.GetComponentInChildren<Text> ().text = text;
        b.GetComponent<Button> ().onClick.AddListener (delegate {
            HandleButton(type);
        });
        b.GetComponent<Button> ().onClick.AddListener (delegate {
            this.buttonPressed(b.GetComponent<Button>());
        });
        b.GetComponent<ButtonInfo> ().buttonCost = cost;
        b.GetComponent<ButtonInfo> ().buttonType = type;
        bc++;
        if (bc * 50 > 250) {
            GetComponent<RectTransform> ().sizeDelta = new Vector2 (237, bc * 50);
        } else {
            GetComponent<RectTransform> ().sizeDelta = new Vector2 (237, 250);
        }
    }

im not sure what the issue is i have the “buttonPrefab” as a public gameobject and i set it in the inspector

If the problem was in AddButton then the error log would say it was inside AddButton. Seeing as the error log ends at UpdateInfo() then I can only assume that UpgradeManager.Instance is null.

Are you setting UpgradeManager.Instance to an instance anywhere? If you are is it possible that UpdateInfo is called before the Instance is set? Or is the Instance destroyed at any point, like at a scene load for example?

you are my hero sir i forgot to set the instance in the start function cant believe i mised something so simple