Unity,在 120hz 设备上构建 Android 时出现问题
我正在开发简单的 2d 项目,精灵从上到下运行,在标准手机 (60hz) 上一切看起来都很平滑,但在 120hz 的 s20+(exynos 990 版本)上,精灵开始轻轻地拉扯、跳跃,失去平滑度。当我关闭 120hz 刷新率时,游戏运行完美。第一步是基于 while 循环,yield return new WaitForEndOfFrame();
,这导致了另一个问题。如果它是基于帧的,那么整个移动速度会快 2 倍,并且游戏无法玩。 所以我决定在 void Update()
上构建运动,并打开 vSync,这解决了 2 倍速度问题,但它对平滑丢失没有帮助,
我试图将帧速率限制为 60 < code>Application.targetFrameRate = 60; vSync 设置为 0,结果相同。
所以我的问题是:有没有可能用它做点什么?当我的应用程序运行时,我可以以某种方式告诉手机关闭 120hz 刷新吗?或者也许统一设置中有一些我不知道的选项,这可以解决我的痛苦。我现在真的处于精神崩溃的边缘。
I'm working on simple 2d project, sprites run from top to bottom and on standard phones (60hz) everything look smooth, but on s20+ (exynos 990 version) with 120hz on, sprites start gently tug, jumps, loosing smoothness. when i turn off 120hz refresh rate, game work perfect. at first move was based on while loop with yield return new WaitForEndOfFrame();
and that was causing another problem. if it was based on frames whole move was 2x faster, and game was unplayable.
so i decided to build movement on void Update()
, and turn on vSync, that solve 2x speed problem but it doesn't help with smooth lose,
I was trying to limit frame rate to 60 by Application.targetFrameRate = 60;
with vSync on 0, same result.
so my question is: Is there any possibility to do something with it? Can i somehow tell phone to turn off 120hz refresh for time when my app is running? or maybe there is some option in unity settings that i don't know about, which can solve my misery. I'm really on the edge of mental breakdown now.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个(打开 120hz 显示模式):
在 Assets 文件夹中创建文件“MainActivity.java”。
打开此文件并粘贴代码:
从项目设置 -> 将
*您的公司名称*
和*您的产品名称*
更改为公司名称和产品名称玩家。转到项目设置 ->玩家->发布设置。勾选“自定义主清单”。
在“Assets\Plugins\Android”中打开文件“AndroidManifest.xml”。
将 android:name=
com.unity3d.player.UnityPlayerActivity
更改为 android:name=com.*您的公司名称*.*您的产品名称*.MainActivity
。请务必在任何脚本中调用
Application.targetFrameRate = Screen.currentResolution.refreshRate;
!更新:修复了 ANDROID 12 中的错误。
https://forum.unity.com/threads/set-screen-refresh-rate-on-android-11.997247/
Try this (to turn on 120hz display mode):
Create file "MainActivity.java" in Assets folder.
Open this file and paste code:
Change
*YOUR COMPANY NAME*
and*YOUR PRODUCT NAME*
to Company Name and Product Name from Project Settings -> Player.Go to Project Settings -> Player -> Publishing Settings. Tick "Custom Main Manifest".
Open file "AndroidManifest.xml" in "Assets\Plugins\Android".
Change android:name=
com.unity3d.player.UnityPlayerActivity
to android:name=com.*YOUR COMPANY NAME*.*YOUR PRODUCT NAME*.MainActivity
.Be sure to call
Application.targetFrameRate = Screen.currentResolution.refreshRate;
in any script!UPDATE: FIXED BUG IN ANDROID 12.
https://forum.unity.com/threads/set-screen-refresh-rate-on-android-11.997247/