Hey guys,
I'm pretty new to Unity, respectively C#, and I'm currently making a small game. So here's my problem:
I have a little timer in the left corner on the screen, telling the player, that he should hurry up, otherwise he'll die. But that's not the big issue. The timer seems not to be that user friendly and so I decided to give him a custom GUI Skin. You know, custom font, font size, and so on. And I named this Custom Style: "Timer". So far so good. As I finished writing the code, I tested it out and I got the following error message: "NullReferenceException: Object reference not set to an instance of an object
Gamemanager.OnGUI () (at Assets/Scripts/Gamemanager.cs:50)". The GameManager is just a regular class.
And this is my code:
public GUISkin skin;
void OnGUI()
{
GUI.skin = skin;
GUI.Label(timerRect, CurrentTime, skin.GetStyle("Timer"));
}
Thanks to anyone who could help me :D
↧