OS.min_window_size 如何在 iOS 视网膜屏幕上工作
我了解您可以在 gdscript 中设置最小和最大窗口大小,以适应您的应用程序在台式机或笔记本电脑上运行并且可调整大小的情况。即
OS.min_window_size = Vector2(500, 500)
OS.max_window_size = Vector2(6000, 4000)
这如何转化为具有视网膜屏幕的 iOS。最小和最大尺寸代表物理像素宽度还是逻辑像素宽度?该文档没有明确说明这一点:
I understand you can set a minimum and maximum window size in gdscript, for the situation when your application is running on a desktop or laptop and is resizable. i.e.
OS.min_window_size = Vector2(500, 500)
OS.max_window_size = Vector2(6000, 4000)
How does this translate into iOS with retina screens. Does the minimum and maximum size represent the physical pixel width, or the logical pixel width? The documentation doesn't make this clear:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,项目设置中有一个名为“允许 Hidpi”的选项,您应该启用该选项才能使用操作系统缩放。 它并不会真正引起问题,但由于向后兼容性,它在 Godot 3.x 中默认被禁用。
现在,您可以查询
OS.get_screen_dpi()
,OS.get_screen_scale()
和OS.get_screen_max_scale()
以了解游戏当前的缩放比例。而且,你是对的,文档没有指定
min_window_size
和max_window_size
是在缩放之前还是之后......答案:我确信
min_window_size
和max_window_size
是缩放后的结果(在任何缩放下,而不是在当前缩放下)。如果我理解正确的话,这是物理像素。找出答案
从现在开始,这个答案就是找出我上面所说的内容。
现在,我相信在 iOS 中 Godot 将始终处于全屏模式。在这种情况下,
min_window_size
和max_window_size
将被忽略。因此,与 iOS 不同的是,这是 OSX 的
set_max_window_size
(来源):那么,让我们看看......
到目前为止,一切都很好。
然后我们就有了这个
zoomed
字段。据我所知,它在全屏上设置为 true,否则设置为 false。因此,这就是我们正在寻找的逻辑:
它是这样的(伪代码):
OS_max_size = max_size / max_scaling
。好的,现在我想看看
setContentMaxSize
:First of all, there is an option in Project Setting called "Allow Hidpi" which you should enable to use OS scaling. It does not really cause problems, but it is disabled by default in Godot 3.x because of backwards compatibility.
Now, you can query
OS.get_screen_dpi()
,OS.get_screen_scale()
andOS.get_screen_max_scale()
to find out about the scaling the game is currently at.And, you are correct, the documentation does not specify if
min_window_size
andmax_window_size
are before or after that scaling…The answer: I'm convinced that
min_window_size
andmax_window_size
are after scaling (at any scaling, not at the current scaling). Which - if I understand correctly - is physical pixels.The figuring out of the answer
From here on, this answer is figuring out what I claim above.
Now, I believe that in iOS Godot will always be in full screen mode. In which case
min_window_size
andmax_window_size
are ignored.So, instead of looking at iOS, this is
set_max_window_size
for OSX (source):So, let us see…
So far so good.
Then we have this
zoomed
field. As far as I can tell it is set to true on full screen, and false otherwise.Thus, this is the logic we are looking for:
It is something like this (pseudo code):
OS_max_size = max_size / max_scaling
.Ok, now I want to see
setContentMaxSize
:????
Ok, there are four possibilities:
setContentMaxSize
sets the maximum size in pixels before scaling. Andmax_window_size
is the maximum size in pixels before scaling.If this was the case, we would set it directly. So, this isn't the case.
setContentMaxSize
sets the maximum size in pixels before scaling. Andmax_window_size
is the maximum size in pixels after scaling.If this was the case, we would have to divide
max_window_size
by the scaling. So, this could be it.setContentMaxSize
sets the maximum size in pixels after scaling. Andmax_window_size
is the maximum size in pixels before scaling.If this was the case, we would have to multiply
max_window_size
by the scaling. So, I don't this is the case.setContentMaxSize
sets the maximum size in pixels after scaling. Andmax_window_size
is the maximum size in pixels after scaling.If this was the case, we would set it directly. So, this isn't the case.
Therefore, unless this is a bug,
max_window_size
is the size in pixels after scaling. And that is the maximum size in pixels at any scaling instead of the current one since it usesget_screen_max_scale()
instead ofget_screen_scale()
. Andmin_window_size
would work the same way.*