namespace UIWidgets.Examples
{
using UnityEngine;
using UnityEngine.Serialization;
using UnityEngine.UI;
///
/// Display current version number.
///
public class SceneVersionNumber : MonoBehaviour, IUpgradeable
{
///
/// File with version number.
///
[SerializeField]
[FormerlySerializedAs("versionFile")]
public TextAsset VersionFile;
///
/// Label to display version number.
///
[SerializeField]
[HideInInspector]
[System.Obsolete("Replaced with LabelAdapter.")]
public Text Label;
///
/// Label to display version number.
///
[SerializeField]
public TextAdapter LabelAdapter;
///
/// Start this instance.
///
public void Start()
{
DisplayVersion();
}
///
/// Display current version number.
///
public void DisplayVersion()
{
if (LabelAdapter != null)
{
var version = string.Format("v{0}", VersionFile.text);
if (LabelAdapter.text != version)
{
LabelAdapter.text = version;
}
}
}
///
/// Upgrade this instance.
///
public virtual void Upgrade()
{
#pragma warning disable 0612, 0618
Utilities.GetOrAddComponent(Label, ref LabelAdapter);
#pragma warning restore 0612, 0618
}
#if UNITY_EDITOR
///
/// Validate this instance.
///
protected virtual void OnValidate()
{
Compatibility.Upgrade(this);
DisplayVersion();
}
#endif
}
}