Camera.aspect 长宽比

var aspect : float

Description描述

The aspect ratio (width divided by height).

长宽比(宽度除以高度)。

By default the aspect ratio is automatically calculated from the screen's aspect ratio, even if the camera is not rendering to full area. If you modify the aspect ratio of the camera, the value will stay until you call camera.ResetAspect(); which resets the aspect to the screen's aspect ratio.

默认的长宽比是从屏幕的长宽比计算得到的,纪实相机没有被渲染到全屏。如果你修改了相机的aspect比,这个值价格保持到你调用camera.ResetAspect(),这将重置长宽比为屏幕的长宽比。

参见:Screen 类.

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public void Awake() {
	if (camera.aspect > 1.0F)
		print("Screen is more wide than tall!");
	else
		print("Screen is more tall than wide!");
	}
}
if (camera.aspect > 1.0)
	print ("Screen is more wide than tall!");
else
	print ("Screen is more tall than wide!");
最后修改:2011年3月6日 Sunday 11:25

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。