I need to show Bundle Version and Bundle Version Code in my application,
but looks like PlayerSettings class has no function to get these two.
Can I get this information like PlayerSettings.iPhoneBundleIdentifier for iPhone application?
Thanks in advance.
Until we add this information you will need to use need to use plugins to access Java to retrieve that info. I believe itâs not available on iPhone either. Please submit a bug report (âfeature requestâ) if you need this.
Thank you.
I will submit a feature request.
So, 5 years ago you did request this feature, is it available now?
Seems like we still cannot get Bundle Version and Bundle Version Code in application?
It could be convenient, because now to show current version in game menu we have to set proper version by hands.
Iâm new to Unity and currently stuck with this too. Anyone has solution?
I use a build script that saves the build info in a text file in a Resources folder, so I can read it during runtime.
What about
PlayerSettings.Android.bundleVersionCode
PlayerSettings.bundleVersion
Wouldnât they work for what you want?
@CesarNascimento Those are only available from Editor scripts, not runtime.
3 years and this is one of the first results on Google when searching for this.
Anyway, using this:
Application.version
You can get a string with the Version of the app (set in PlayerSettings).
This works on Android and iOS, and I believe in PC too. But I donât know yet a way to get the Bundle Package Version Code (or Bundle Version, in iOS) in runtime yet.
Maybe this can be usefull: c# - Get App Bundle Version in Unity3d - Stack Overflow
Hi, you can use this code to get Bundle version code or package name.
AndroidJavaClass up = new AndroidJavaClass(âcom.unity3d.player.UnityPlayerâ);
var ca = up.GetStatic(âcurrentActivityâ);
AndroidJavaObject packageManager = ca.Call(âgetPackageManagerâ);
var pInfo = packageManager.Call(âgetPackageInfoâ, Application.bundleIdentifier, 0);
Debug.Log(âversionCode:â + pInfo.Get(âversionCodeâ));
Hmm, that code doesnât compile for me, even when building for Android;
Is there still no cross-platform way to get the bundle version?
@JoeStrout Unfortunately thereâs not. Unity is considering an unified API call for this (response to non-public Case 1024033).
Since Unity 5.6.0b6 the API call you receive the error for has changed:
Itâs rather troubling that this feature has been requested 9 years ago and still nothing. Iâm not certain of the volume of feature requests, but what is the rate of completion for feature requests anyway? Are those given any priority at all?
I feel like this could be a very easy change to make on UTâs side, can we get access to the bundle version code (Android) or build number (iOS) during runtime? The same way we now have access to the bundle identifier in Application.identifier - Canât there be an Application.buildNumber ?
Bumping, have to set text files EVERY time I upload, just that extra stupid step ;/
Agreed. This is hard for us to do, but easy for Unity, with no unpleasant side-effects that I can see⌠weird that we still donât have it.
Too bad we canât access this feature. I am afraid I will forget to change the version code from the editor text.
But!!!
Texmeshpro versionText;
String version;
Void Awake()
{
version = Application.version
versionText. text = version;
}
//seems to work just fine.
But it is available.
You can set your game version string via
PlayerSettings.bundleVersion
And you can set your bundleVersionCode for Android via
PlayerSettings.Android.bundleVersionCode
or for iOS
PlayerSettings.iOS.buildNumber
But PlayerSettings is in the UnityEditor namespace. Itâs not available at runtime, is it?
In general, in cases like these, you could write a pre-build script/hook that, at build time, reads the info from PlayerSettings and generates a file (JSON, scriptableObject, whatever) that you can read at runtime to populate the text field with.
Details on how to do that would make an excellent blog or forum post!