应用程序支持的最大纵横比。
此值以十进制形式表示(长边 / 短边)。它不能设置为低于 1.86
的值,该值与 16:9
的纵横比相匹配。默认情况下,它设置为 2.4
,这意味着应用程序支持所有纵横比最高为 21.6:9
的设备。有关更多信息,请参阅 支持不同屏幕尺寸。
using UnityEditor; using UnityEditor.Build; using UnityEngine;
public class MaxAspectRatio : MonoBehaviour { [MenuItem("Build/Android Max Aspect Ratio Example")] public static void AndroidArchitectures() { PlayerSettings.SetScriptingBackend(NamedBuildTarget.Android, ScriptingImplementation.IL2CPP); PlayerSettings.Android.targetArchitectures = AndroidArchitecture.ARM64;
//Set the maxAspectRatio to the default value PlayerSettings.Android.maxAspectRatio = 2.4f;
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); } }