Created
February 4, 2016 18:51
-
-
Save miguelSantirso/5f3e75ba4dcc0d9b9067 to your computer and use it in GitHub Desktop.
[Unity] Auto update Text with the bundle version every time you build
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using UnityEngine.UI; | |
[ExecuteInEditMode] | |
public class BuildNumberLabel : MonoBehaviour | |
{ | |
#region inspector properties | |
[SerializeField] | |
private string format = "v. {0}" | |
#endregion | |
#if UNITY_EDITOR | |
void Awake() | |
{ | |
// This works because Unity opens all scenes before creating a build | |
var label = GetComponent<Text>(); | |
label.text = String.Format(format, UnityEditor.PlayerSettings.bundleVersion); | |
} | |
#endif | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment