検証環境
- Unity:2019.2.7f2
- VisualStudio:2019
- Device:HoloLens2
コード
UnityEngine.Application.version で取れるのは、PlayerSettings の Version である。
一方、HoloLens のアプリケーションのバージョンはこれとは別で、Unity ビルドで出力したプロジェクトや MRTK の BuildWindow で見る(設定する)ことができる。
このバージョン番号をスクリプトで取得するには以下のようにする。
#if !UNITY_EDITOR && UNITY_WSA using Windows.ApplicationModel; #endif public static string GetAppVersion() { #if !UNITY_EDITOR && UNITY_WSA var package = Package.Current; var packageId = package.Id; var version = packageId.Version; return $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}"; #else return Application.version; #endif }
実行結果