Struct Camera2D
Namespace: Unity.Tiny.Core2D
Syntax
public struct Camera2D : IComponentData
Fields
backgroundColor
Specifies the background color this camera should render before rendering the scene when clearFlags is set to SolidColor.
Declaration
public Color backgroundColor
Field Value
Type | Description |
---|---|
Color |
clearFlags
Specifies how to clear this camera's viewport before rendering.
Declaration
public CameraClearFlags clearFlags
Field Value
Type | Description |
---|---|
CameraClearFlags |
cullingMask
Specifies which components to consider when culling entities according to the cullingMode.
Declaration
public uint cullingMask
Field Value
Type | Description |
---|---|
System.UInt32 |
Remarks
The cullingMask is a bit mask that references the 16 CameraLayer0 to CameraLayer15 components. An easy way to set the bit mask is using binary literals 0b0000_0000_0000_0000_0000_0000_0000_0000 and setting desired entries to 1. 0b1000_0000_1000_0010 for example would mean the set of CameraLayer1, CameraLayer7, and CameraLayer15. The upper 16 bits of the cullingMask can be used for custom components. Those components have to be registered with the DisplayListSystem via SetCameraLayerComponent. Examples:
- cullingMode = CameraCullingMode.NoCulling -> cullingMask is ignored, camera renders all entities
- cullingMode = CameraCullingMode.All, cullingMask = 0b001001 -> only entities that have at least both the CameraLayer0 and CameraLayer3 component layer are rendered by this camera
- cullingMode = CameraCullingMode.Any, cullingMask = 0b000101 -> only entities that have at least one of CameraLayer0 and CameraLayer2 component layer are rendered by this camera
- cullingMode = CameraCullingMode.None, cullingMask = 0b010001 -> render all entities except those that have either CameraLayer0 or CameraLayer4 components set
cullingMode
Specifies which CameraCullingMode option this camera uses to interpret its culling mask.
Declaration
public CameraCullingMode cullingMode
Field Value
Type | Description |
---|---|
CameraCullingMode |
Remarks
The culling mask is specified via the cullingMask field directly
depth
The camera's render order relative to other cameras.
Declaration
public float depth
Field Value
Type | Description |
---|---|
System.Single |
Remarks
Cameras with lower values render first. Cameras with higher values render on top of cameras with lower values.
halfVerticalSize
Specifies half of the vertical size in world units.
Declaration
public float halfVerticalSize
Field Value
Type | Description |
---|---|
System.Single |
Remarks
The horizontal size is calculated from the output display size and aspect ratio. The Transform component's world position defines the camera origin's location, size, and rotation.
rect
Specifies the coordinates of the viewport rectangle in the output frame that this camera should render to.
Declaration
public Rect rect
Field Value
Type | Description |
---|---|
Rect |
Properties
Default
Default Camera2D preset.
Declaration
public static Camera2D Default { get; }
Property Value
Type | Description |
---|---|
Camera2D |