我想知道是否可以在 Unity 中获取窗口缩放和布局(以百分比为单位)。 可以通过以下方式在 native C# 应用程序中执行此操作:
public static int GetWindowsScaling()
{
return (int)(100 * Screen.PrimaryScreen.Bounds.Width / SystemParameters.PrimaryScreenWidth);
}
在 Unity 中可以做同样的事情吗?
最佳答案
看看这是否有帮助 Screen.DPI 。这将为您提供相对于引用 DPI(通常为 96)的比例因子。
此外,您还可以使用 Screen.width
和 Screen.height
获取窗口宽度和高度(以像素为单位)。
希望这些有所帮助。
关于c# - 在 Unity 中获取窗口比例和布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76530731/