ゲームのバージョン確認・変更と表示メモです。※Unity本体のバージョン管理ではありません。
ゲームのバージョンを確認、変更する手順

- 「Edit」>「Project Settings」を開きます。
- 「Player」タブ内のVersionからゲームのバージョン確認・変更が行えます。
ゲームのバージョンを表示する
ゲームのバージョンをスクリプトから取り扱う際には、
読み取り専用の文字列(string)「Application.version」を使用します。
Debug.Logによる確認

using UnityEngine;
namespace BlueBreath
{
public class VersionTMP : MonoBehaviour
{
void Start()
{
Debug.Log("App Version : " + Application.version);
}
}
}
UIに表示する例

using UnityEngine;
using TMPro;
namespace BlueBreath
{
public class VersionTMP : MonoBehaviour
{
[SerializeField]
private TextMeshProUGUI textMeshPro;
void Start()
{
textMeshPro.SetText("App Version : " + Application.version);
}
}
}
参考
Application.version, Unityスクリプトリファレンス
コメント