Legacy Documentation: Version 4.6.2
Language: English
  • C#
  • JS
  • Boo

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Camera.aspect

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual
public var aspect: float;
public float aspect;
public aspect as 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. See Also: camera component, Screen class.

	if (camera.aspect > 1.0)
		print ("Screen is more wide than tall!");
	else
		print ("Screen is more tall than wide!");
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void Example() {
        if (camera.aspect > 1.0F)
            print("Screen is more wide than tall!");
        else
            print("Screen is more tall than wide!");
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	def Example() as void:
		if camera.aspect > 1.0F:
			print('Screen is more wide than tall!')
		else:
			print('Screen is more tall than wide!')