Hello, I want to display in my Unity game which version of unity I am running my app in. I managed to create a script which does that but for some reason I get v0.0.0 as my output. Can someone help me understand why I am getting this output?
Here is my code. I hope it helps:
using UnityEngine;
using System.Collections;
using System.Reflection;
[ExecuteInEditMode]
public class TestGUI : MonoBehaviour {
/// <summary>
/// The name.
/// </summary>
public const string name = "Leroy Jenkins";
/// <summary>
/// The testdate.
/// </summary>
public const string testdate = "11/08/2014";
/// <summary>
/// The version.
/// </summary>
private string version;
/// <summary>
/// The version.
/// </summary>
public string Version
{
get {
if (version == null) {
version = Assembly.GetExecutingAssembly ().GetName ().Version.ToString ();
}
return version;
}
}
/// <summary>
/// The p GUI rect.
/// </summary>
private Rect pGUIRect;
// Use this for initialization
void Start () {
pGUIRect = new Rect (0, 0, 100, 100);
}
/// <summary>
/// Raises the GUI event.
/// </summary>
void OnGUI()
{
GUI.Box (pGUIRect, GUIContent.none);
GUI.Label (new Rect(0,0,100,100),testdate, GUIStyle.none);
GUI.Label (new Rect(0,30,100,100),string.Format ("v{0}", Version), GUIStyle.none);
}
}