Version: 2023.2
public static int bundleVersionCode ;

描述

Android 捆绑包版本代码。

应该小于100000 才能使 buildApkPerCpuArchitecture 生成有效的版本代码。

using UnityEditor;
using UnityEditor.Build;
using UnityEngine;
public class BundleVersionCodeExample : MonoBehaviour
{
    [MenuItem("Build/Android Bundle Version Code Example")]
    public static void IncrementingBundleVersionExample()
    {
        PlayerSettings.SetScriptingBackend(NamedBuildTarget.Android, ScriptingImplementation.IL2CPP);
        PlayerSettings.Android.targetArchitectures = AndroidArchitecture.ARM64;
        PlayerSettings.Android.bundleVersionCode++;
        BuildPlayerOptions options = new BuildPlayerOptions();
        options.scenes = new[] { "Assets/Scenes/SampleScene.unity" };
        options.locationPathName = "Builds/AndroidBuild.apk";
        options.target = BuildTarget.Android;
        options.targetGroup = BuildTargetGroup.Android;
        BuildPipeline.BuildPlayer(options);
    }
}