c# - 在 Unity 中更改分辨率时如何修复黑屏
问题描述
我制作了一个 2d 游戏,在构建它时运行良好,但在我实施分辨率更改后,它无法正确渲染所有内容,仅渲染玩家。
我试过删除这些行,但没有帮助。之后的每个构建都具有该分辨率(我可以看到它被应用于播放器)并且无法渲染其余部分。
我在游戏开始时使用它。
Screen.SetResolution(160, 144, true, 60);
我也得到了这些,但我不确定它们是否相关。
Multiple managers are loaded of type: InputManager
Multiple managers are loaded of type: GraphicsSettings
Multiple managers are loaded of type: PhysicsManager
Multiple managers are loaded of type: QualitySettings
Multiple managers are loaded of type: Physics2DSettings
Multiple managers are loaded of type: VFXManager
解决方案
假设您使用的是桌面:
要在桌面平台上设置特定的全屏模式,请使用接受 FullScreenMode 参数的方法重载。
public static void SetResolution(int width, int height, FullScreenMode fullscreenMode, int preferredRefreshRate = 0);
https://docs.unity3d.com/ScriptReference/Screen.SetResolution.html
fullscreenMode 参数可以是以下类型之一:
ExclusiveFullScreen
FullScreenWindow
MaximizedWindow
Windowed
https://docs.unity3d.com/ScriptReference/FullScreenMode.html
IE:
Screen.SetResolution(160, 144, FullScreenMode.ExclusiveFullscreen, 60);
推荐阅读
- javascript - react中如何实现usePrevious
- html - 使用 Pandoc 从 HTML 转换为 Markdown 时为代码块添加正确的语法名称
- entity-framework-core - 在当前工作目录中发现了多个项目。使用 --project 选项
- java - 如何在 Spring Boot jpa 中将 @OrderBy 与 Embeddable 一起使用
- java - 仅为 ONE 测试启用 spring 数据源
- reactjs - 反应如何覆盖父级中的子函数,
- python - 2d 列表的合并列表,它的分离正确,但是当它全部返回时,它是错误的,
- python - 熊猫:用正则表达式替换“类别”dtype
- java - 基于简单查找进行数据翻译的最佳实践 Apache Camel 方法
- mysql - 具有顺序主自动增量键的数据库记录是否可能位于 INNODB 表的同一页上?