Unity 4.5 to 5 problem
Hello, i watch one tutorial to create a 2D Game and i think that i have problem with the different versions of Unity or ? maybe something else. The first Screen is the tutorial and the second my Code. I noticed that the numbers inside the string appeared red but in tutorial appeared green. i thought that maybe this is due to the older version of unity. But when i pressed to play i had this error.
NullReferenceException: Object reference not set to an instance of an object GameHud.OnGUI () (at Assets/Code/GameHud.cs:15)
Anyone who can help please ! i am confused !
here is and my code :
using UnityEngine;
public class GameHud : MonoBehaviour { public GUISkin Skin;
public void OnGUI()
{
GUI.skin = Skin;
GUILayout.BeginArea(new Rect(0, 0, Screen.width, Screen.height));
{
GUILayout.BeginVertical(Skin.GetStyle("GameHud"));
{
GUILayout.Label(string.Format("Points: {0}", GameManager.Instance.Points), Skin.GetStyle("PointsText"));
var time = LevelManager.Instance.RunningTime;
GUILayout.Label(string.Format(
"{0:00}:{1:00} with {2} bonus",
time.Minutes + (time.Hours * 60),
time.Seconds,
LevelManager.Instance.CurrentTimeBonus), Skin.GetStyle("TimeText"));
}
GUILayout.EndVertical();
}
GUILayout.EndArea();
}
}
Your answer
Follow this Question
Related Questions
Pick a random string from a string array C# 1 Answer
use the tag of a gameobject to assign a string variable 1 Answer
Convert UI Text into string? 1 Answer
checking numbers in strings 2 Answers