You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Unity构建游戏在一加手机(如OnePlus 7T)无法横屏运行求助

针对OnePlus 7T等一加机型无法全屏横屏的解决方案
  • 检查系统权限设置
    一加手机自带的「全屏显示」权限可能默认未开启:

    1. 打开手机「设置」→「显示」→「全屏显示」
    2. 找到你的游戏应用,开启「全屏显示」和「显示刘海区域」选项
  • 补充Unity Player Settings配置
    在现有设置基础上,追加以下配置:

    1. 进入Player Settings > Android > Resolution and Presentation
      • 确认「Default Orientation」设为目标横屏方向(如Landscape Left)
      • 仅勾选「Auto Rotation」中对应的横屏选项,取消所有竖屏选项
      • 关闭「Use Native On-Screen Keyboard」选项
    2. 切换「Rendering Path」为Forward(一加机型对该路径兼容性更优)
  • 自定义AndroidManifest.xml配置
    手动修改安卓清单文件,添加一加专属适配参数:

    <!-- 在<application>标签内添加 -->
    <meta-data android:name="android.notch_support" android:value="true" />
    <meta-data android:name="com.oneplus.screen.fullscreen" android:value="true" />
    <meta-data android:name="com.oneplus.screen.orientation" android:value="landscape" />
    
    <!-- 确保Activity使用全屏主题 -->
    <activity android:name="com.unity3d.player.UnityPlayerActivity"
              android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
              android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density">
    
  • 代码强制全屏与横屏
    在Unity中添加脚本,启动时强制设置屏幕状态:

    using UnityEngine;
    
    public class ForceScreenSettings : MonoBehaviour
    {
        void Start()
        {
            // 锁定横屏
            Screen.orientation = ScreenOrientation.LandscapeLeft;
            // 强制全屏
            Screen.fullScreen = true;
    
            #if UNITY_ANDROID
            // 隐藏安卓状态栏与导航栏
            AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
            AndroidJavaObject window = currentActivity.Call<AndroidJavaObject>("getWindow");
            AndroidJavaClass layoutParams = new AndroidJavaClass("android.view.WindowManager$LayoutParams");
            
            int flagFullscreen = layoutParams.GetStatic<int>("FLAG_FULLSCREEN");
            int flagLayoutNoLimits = layoutParams.GetStatic<int>("FLAG_LAYOUT_NO_LIMITS");
            
            window.Call("addFlags", flagFullscreen);
            window.Call("addFlags", flagLayoutNoLimits);
            #endif
        }
    }
    

    将该脚本挂载到场景的常驻GameObject上即可。

  • 尝试LTS版本Unity构建
    虽然使用了最新版本,但Unity LTS版本(如2020.3.x)对安卓设备的适配更稳定,可尝试降级到对应LTS的最新补丁版本重新构建测试。

内容的提问来源于stack exchange,提问作者Alwaystrying

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.09 10:43:03