Scripting API

Camera

class in UnityEngine · UnityEngine.CoreModule · inherits from Behaviour

49 of 129 of Unity's membersUnity's documentation
In Tassix

A camera. Matrices follow Unity: projection in OpenGL clip space, and a view matrix that looks down camera-space -Z (world +Z flipped). Verified against Unity in conformance/recordings/rendering_data.jsonl.

Fields 3

static CameraCallback? onPostRender
static CameraCallback? onPreCull

Built-in render pipeline: each camera, before culling, before rendering and after (not with URP, as in Unity).

static CameraCallback? onPreRender

Properties 37

static Camera[] allCameras { get; }
static int allCamerasCount { get; }
bool allowHDR { get; set; }

Whether the camera may render in HDR (Tassix: its post-processing decides).

bool allowMSAA { get; set; }

Whether the camera may use multisampling (Tassix doesn't multisample).

float anamorphism { get; set; }
float aperture { get; set; }
float aspect { get; set; }

Width / height. Follows the screen until set; ResetAspect undoes that.

Color backgroundColor { get; set; }
float barrelClipping { get; set; }
int bladeCount { get; set; }
Matrix4x4 cameraToWorldMatrix { get; }
CameraType cameraType { get; set; }

What the camera renders for: the game, here.

CameraClearFlags clearFlags { get; set; }
int cullingMask { get; set; }

Layers the camera draws (event raycasters filter by it too).

static Camera? current { get; }

The camera rendering now (during its callbacks), else null.

Vector2 curvature { get; set; }
float depth { get; set; }
DepthTextureMode depthTextureMode { get; set; }

Which depth textures the camera makes for shaders (kept: the renderer makes the depth texture project shaders read anyway).

float farClipPlane { get; set; }
float fieldOfView { get; set; }
float focalLength { get; set; }

Millimetres, for the sensor's height (the vertical field of view).

float focusDistance { get; set; }
GateFitMode gateFit { get; set; }
int iso { get; set; }
Vector2 lensShift { get; set; }
static Camera? main { get; }

The first enabled camera tagged "MainCamera", as in Unity. Scenes without tagged cameras fall back to the first enabled camera.

float nearClipPlane { get; set; }
bool orthographic { get; set; }
float orthographicSize { get; set; }
int pixelHeight { get; }
int pixelWidth { get; }
Matrix4x4 projectionMatrix { get; }
Vector2 sensorSize { get; set; }
float shutterSpeed { get; set; }
RenderTexture? targetTexture { get; set; }

The render texture the camera draws into instead of the screen (before the screen's cameras); null for the screen.

bool usePhysicalProperties { get; set; }
Matrix4x4 worldToCameraMatrix { get; }

World to camera space; camera space looks down -Z.

Methods 12

static float FieldOfViewToFocalLength(float fieldOfView, float sensorSize)
static float FocalLengthToFieldOfView(float focalLength, float sensorSize)
void Render()

Renders the camera at once. Not supported yet: cameras render with the frame (a camera with a target texture draws into it every frame); says so once.

void ResetAspect()
Ray ScreenPointToRay(Vector3 position)
Vector3 ScreenToViewportPoint(Vector3 position)
Vector3 ScreenToWorldPoint(Vector3 position)
Ray ViewportPointToRay(Vector3 position)

A ray from the near plane through viewport point (x, y).

Vector3 ViewportToScreenPoint(Vector3 position)
Vector3 ViewportToWorldPoint(Vector3 position)

The world point at viewport (x, y), position.z in front of the camera.

Vector3 WorldToScreenPoint(Vector3 position)
Vector3 WorldToViewportPoint(Vector3 position)

x, y in [0, 1] across the view; z is the distance in front of the camera.

Not in Tassix yet 80

AddCommandBuffer AddCommandBufferAsync CalculateFrustumCorners CalculateObliqueMatrix CalculateProjectionMatrixFromPhysicalProperties CopyFrom CopyStereoDeviceProjectionMatrixToNonJittered FieldOfViewToFocalLength FocalLengthToFieldOfView GetAllCameras GetCommandBuffers GetGateFittedFieldOfView GetGateFittedLensShift GetStereoNonJitteredProjectionMatrix GetStereoProjectionMatrix GetStereoViewMatrix HorizontalToVerticalFieldOfView RemoveAllCommandBuffers RemoveCommandBuffer RemoveCommandBuffers RenderDontRestore RenderToCubemap RenderWithShader Reset ResetCullingMatrix ResetProjectionMatrix ResetReplacementShader ResetStereoProjectionMatrices ResetStereoViewMatrices ResetTransparencySortSettings ResetWorldToCameraMatrix SetReplacementShader SetStereoProjectionMatrix SetStereoViewMatrix SetTargetBuffers SetupCurrent SubmitRenderRequest TryGetCullingParameters VerticalToHorizontalFieldOfView activeTexture actualRenderingPath allowDynamicResolution areVRStereoViewMatricesWithinSingleCullTolerance cameraType clearStencilAfterLightingPass commandBufferCount cullingMatrix depthTextureMode eventMask forceIntoRenderTexture isProcessingRenderRequest kMaxAperture kMaxBladeCount kMinAperture kMinBladeCount layerCullDistances layerCullSpherical nonJitteredProjectionMatrix opaqueSortMode overrideSceneCullingMask pixelRect previousViewProjectionMatrix rect renderCloudsInSceneView renderingPath scaledPixelHeight scaledPixelWidth scene sceneViewFilterMode stereoActiveEye stereoConvergence stereoEnabled stereoSeparation stereoTargetEye targetDisplay transparencySortAxis transparencySortMode useJitteredProjectionMatrixForTransparentRendering useOcclusionCulling velocity