Skip to content

Instantly share code, notes, and snippets.

@miguelSantirso
Created February 4, 2016 18:51
Show Gist options
  • Save miguelSantirso/5f3e75ba4dcc0d9b9067 to your computer and use it in GitHub Desktop.
Save miguelSantirso/5f3e75ba4dcc0d9b9067 to your computer and use it in GitHub Desktop.
[Unity] Auto update Text with the bundle version every time you build
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