Natively gets the version code on Android or the bundle version on iOS. In Unity it equates to the values set to Bundle Version Code (Android) or Build (iOS) in Player Settings.
This package assumes that for both platforms this is an integer value. The iOS bundle version can technically be a string, but common practice is to use an incrementing integer synced for both platforms.
using MobileVersionCode;
using UnityEngine;
public class TestVersionCode : MonoBehaviour
{
void Start()
{
Debug.Log($"Version Code: {VersionCode.GetVersionCode()}");
}
}
Open Windows > Package Manager
. Click the add button in the upper left, then Add package from git URL
. Paste in the URL: https://github.com/natewilliford/unity-mobile-version-code.git
.