private Vector2 ResetSize(float _width, float _height, float screenWidth = 1920, float screenHeight = 1080)
{
float tempWidth;
float tempHeight;
if (_width < screenWidth && _height < screenHeight)
{
tempWidth = _width;
tempHeight = _height;
}
else
{
if (_width > _height)//当图片(长>高)
{
if (_width / _height > screenWidth / screenHeight)//当图片比例大于屏幕比例
{
tempWidth = screenWidth;
if (screenWidth < _width)
tempHeight = _height * (screenWidth / _width);
else
tempHeight = _height / (screenWidth / _width);
}
else
{
tempHeight = screenHeight;
if (screenHeight < _height)
tempWidth = _width * (screenHeight / _height);
else
tempWidth = _width / (screenHeight / _height);
}
}
else//当图片(长<=高)
{
tempHeight = screenHeight;
if (screenHeight > _height)
tempWidth = _width / (screenHeight / _height);
else
tempWidth = _width * (screenHeight / _height);
}
}
return new Vector2(tempWidth, tempHeight);
}
11-24
6288
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-30
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交