I’ve seen a few answers but no matter what I try I get no lucky
// Create an object of main menu
public MainMenu mainMenu;
public int gEnzyme;
From the MainMenu script I want to call a variable called enzyme of type int
Within the OnGUI function I assign the variable to the MainMenu variable:
gEnzyme = mainMenu.enzyme;
I’ve done this as I am trying to display the integer within a Box using ‘.ToString()’.
GUI.Box (new Rect(0, 300, 100, 50), enzyme.ToString());
I’ve tried all different ways of trying this even ones I feel are pointless just to see.
I’ve probably made a rookie error somewhere
The error I keep getting is:
NullReferenceException: Object reference not set to an instance of an object Game.OnGUI ()
Thank you in advance!
Ignore the enzyme.ToString() forgot to repost the updated one. It does actually say gEnzyme.ToString(), but still doesn't work.
– acesouthall