Android 构建目标的 CPU 架构集。
using UnityEditor; using UnityEditor.Build; using UnityEngine;
public class TargetArchitecturesExample : MonoBehaviour { [MenuItem("Build/Android Target Architectures Example")] public static void TargetArchitectures() { PlayerSettings.SetScriptingBackend(NamedBuildTarget.Android, ScriptingImplementation.IL2CPP);
//Set the targetArchitecture to ARM64 AndroidAchitecture PlayerSettings.Android.targetArchitectures = AndroidArchitecture.ARM64;
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); } }