【unity实用技能】u3d 获取屏幕的宽高

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/chrisfxs/article/details/68490470

想搞个全屏Sprite,获取Screen.Width什么的都不对。

因为这个跟你的Camera的aspect有关。


所以有个很简单的方法


首先一般你的项目都会限度是以宽还是高做基准来拉伸

我们是横版游戏,所以是宽做基准

我们的宽定的标准值为1334.


所以是这样

public int GetScreenHeight(GameObject go)
{
	Camera camera = NGUITools.FindInParents<Camera>(go);
	int height = Mathf.CeilToInt(1334 / camera.aspect);
	return height;
}



猜你喜欢

转载自blog.csdn.net/chrisfxs/article/details/68490470
今日推荐