void SetResolution() {
float heightScal = 9.0f;
float widthScal = 16.0f;
int screenWidth = Screen.currentResolution.width;
int screenHeight = Screen.currentResolution.height;
int width = Screen.width;
int height = Screen.height;
if (((widthScal * height) / heightScal) > screenWidth)
{
int h = (int)((heightScal * screenWidth) / widthScal);
int w = (int)((widthScal * h) / heightScal);
Screen.SetResolution(w, h, true);
}
else
{
int w = (int)((widthScal * screenHeight) / heightScal);
int h = (int)((heightScal * screenWidth) / widthScal);
Screen.SetResolution(w, h, true);
}
}
unity发布exe固定宽高比
最新推荐文章于 2024-01-24 09:54:15 发布