Android 包版本代码。
对于 buildApkPerCpuArchitecture 生成有效的版本代码,此值应小于 100000。
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); } }