Camera.aspect 长宽比

var aspect : float


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.


参见: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!");
		print("Screen is more tall than wide!");
if (camera.aspect > 1.0)
	print ("Screen is more wide than tall!");
	print ("Screen is more tall than wide!");
Page last updated: 2011-3-6