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

Unity:如何修复Steam Deck上的1:1方形宽高比问题

修复Steam Deck上Unity游戏1:1宽高比黑边问题

一、Unity构建层面设置调整

  1. 分辨率与显示设置
    • 打开Edit > Project Settings > Player,进入Resolution and Presentation标签:
      • 将Aspect Ratio设置为Free Aspect或Match Width or Height(根据游戏响应式逻辑选择,优先匹配宽度或高度)
      • 把Fullscreen Mode改为Borderless Window或Exclusive Fullscreen,Steam Deck对无边框窗口兼容性更好
      • 取消勾选Fixed Resolution(若存在),确保游戏支持自适应分辨率
  2. Linux平台专属设置
    • 切换到Other Settings标签,将Rendering API设置为Vulkan(Steam Deck默认渲染API,兼容性最优)
    • 开启Allow Window Resizing选项

二、代码层面强制适配Steam Deck分辨率

在游戏启动的首个场景中添加如下脚本,强制设置正确的屏幕参数:

using UnityEngine;

public class SteamDeckScreenFix : MonoBehaviour
{
    void Start()
    {
        // Steam Deck原生分辨率1280×800,宽高比16:10
        int targetWidth = 1280;
        int targetHeight = 800;

        // 强制设置全屏窗口模式与对应分辨率
        Screen.SetResolution(targetWidth, targetHeight, FullScreenMode.FullScreenWindow);
        // 锁定横屏方向
        Screen.orientation = ScreenOrientation.LandscapeLeft;

        // 适配相机宽高比(如果是2D正交相机)
        Camera mainCamera = Camera.main;
        if (mainCamera != null && mainCamera.orthographic)
        {
            mainCamera.aspect = (float)targetWidth / targetHeight;
            // 保持相机可视范围一致
            mainCamera.orthographicSize = mainCamera.orthographicSize * ((float)targetHeight / Screen.height);
        }
    }
}

将该脚本挂载到场景中的任意持久化GameObject上(比如空的Manager对象)。

三、Steam启动选项配置

在Steam库中右键游戏 → 属性 → 启动选项,添加以下参数强制指定分辨率:

-screen-width 1280 -screen-height 800 -screen-fullscreen 1

四、重置本地游戏配置

若上述方法无效,可能是本地保存了错误的显示设置:

  • 在Steam Deck上找到游戏的本地配置目录(通常在~/.local/share/Steam/steamapps/common/[你的游戏名]/或~/.config/unity3d/[你的公司名]/[你的游戏名]/)
  • 删除PlayerPrefs文件或config文件夹,重置游戏显示参数

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.09 03:42:47