docs.unity3d.com
  • Manual
  • Scripting API
  • Changelog
  • License
Show / Hide Table of Contents
    • AddCollectorMenuAttribute
    • CameraGrab_Editor
    • CaptureCollector
    • JpegEncoder
    • JpegEncoder.Flags
    • JpegEncoder.PixelFormat
    • JpegEncoder.SubSample
    • PngEncoder
    • PngEncoder.ColorType
    • PngEncoder.PngParam
  • Unity.Simulation
    • AggregatedSample
    • AggregationEvent
    • ArrayCast
    • ArrayUtilities
    • AsyncRequest
    • AsyncRequest.ExecutionContext
    • AsyncRequest.Result
    • AsyncRequest.State
    • AsyncRequest<T>
    • BaseDataConsumer<T>
    • BaseDataConsumer<T>.Uploadable
    • BaseLogger
    • BatchReadback
    • CameraGrab
    • CaptureCamera
    • CaptureCamera.CaptureState
    • CaptureCamera.Channel
    • CaptureCamera.ReadbackCompletionDelegate
    • CaptureCamera.RequestCompletionDelegate
    • CaptureGPUBuffer
    • CaptureImageEncoder
    • CaptureImageEncoder.ImageFormat
    • CaptureOptions
    • CaptureRenderTexture
    • Category
    • ChannelGrab
    • ChunkedStream
    • CollectorBase
    • CollectorBase.ConsumeCollectorReport
    • CollectorElement
    • CollectorsBaseEditor
    • CollectorsList
    • ContentType
    • ContinuousEvents
    • ContinuousEvents.EventCollectionDelegate
    • ContinuousEvents.EventDispatchDelegate
    • CoreProfilerUtils
    • CounterEvent
    • CounterEventData
    • DXChunkedStream
    • DXFile
    • DXFormat
    • DXManager
    • DXTimeLogger
    • DataCapturePaths
    • DepthGrab
    • DirectoryNameComponent
    • Dispatcher
    • EventBase
    • ExecUtility
    • ExitPlaymode
    • ExtensionNameComponent
    • FileNameComponent
    • FileProducer
    • ForceFlip
    • Format
    • FrameCountCondition
    • FrameLimit
    • FrameNumberNameComponent
    • GeneralUtilities
    • GraphicsUtilities
    • ICondition
    • IDataProduced
    • IGlobalProfilerDataDispatcher
    • IgnoreCollectorAttribute
    • LabelNameComponent
    • LambdaJob
    • LambdaJob.DelegateType
    • Log
    • Log.Level
    • Logger
    • LoggerSuffixOption
    • Manager
    • Manager.NotificationDelegate
    • Manager.TickDelegate
    • NameComponent
    • NameGenerator
    • Options
    • PackageImportTests
    • PathUtility
    • PerfStatsManager
    • PlayerResolution
    • PlayerResolutionSettings
    • ProfilerManager
    • ProfilerProperties
    • ProfilerReport
    • ProfilerSamplingEvent
    • ReadbackRequest
    • RenderPassCallbackDelegate
    • RenderingPipelineType
    • ReportingUtils
    • SRPSupport
    • Sample
    • SampleProfilerCollector
    • ScreenCapture
    • SequenceNameComponent
    • SequencedPathName
    • SimSecondsCondition
    • SimulationProfiler
    • SimulationProfilerBase
    • SimulationProfilerEditor
    • TestUtility
    • ThreadUtility
    • TimeLimit
    • TimeLogger
    • TimeScale
    • TimeScaleEditor
    • TimeUtility
    • Timer
    • TimerSource
    • TimestampNameComponent
    • URPCallbackPass
    • URPCaptureRendererFeature
    • UnityVersion
    • WallSecondsCondition

Class CaptureCamera

Capture class for cameras. Supports Color, Depth, MotionVectors. Captures supported channels to file system and notifies Manager.

Inheritance
object
CaptureCamera
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Unity.Simulation
Assembly: Unity.Simulation.Capture.dll
Syntax
public static class CaptureCamera

Fields

SRPSupport

Support for Scriptable Render Pipeline. SRP works a little differently, this abstraction allows for custom capture options when using SRP. The default implementation queues camera captures, and dispatches on RenderPipelineManager.endFrameRendering. You can provide your own implementation of QueueCameraRequest, and dispatch that when appropriate.

Declaration
public static SRPSupport SRPSupport
Field Value
Type Description
SRPSupport

Properties

scriptableRenderPipeline

Property for determining whether or not a scriptable render pipeline is enabled or not.

Declaration
public static bool scriptableRenderPipeline { get; }
Property Value
Type Description
bool

Methods

Capture(Camera, Func<AsyncRequest<CaptureState>, Result>, GraphicsFormat, Func<AsyncRequest<CaptureState>, Result>, GraphicsFormat, Func<AsyncRequest<CaptureState>, Result>, GraphicsFormat, bool)

Main Capture entrypoint.

Declaration
[Obsolete("Capture with boolean flipY has been deprecated. Use the version with ForceFlipY instead.")]
public static AsyncRequest<CaptureCamera.CaptureState> Capture(Camera camera, Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> colorFunctor = null, GraphicsFormat colorFormat = GraphicsFormat.R8G8B8A8_UNorm, Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> depthFunctor = null, GraphicsFormat depthFormat = GraphicsFormat.R16_UNorm, Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> motionFunctor = null, GraphicsFormat motionFormat = GraphicsFormat.R16_UNorm, bool flipY = false)
Parameters
Type Name Description
Camera camera

The Camera to capture data from.

Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> colorFunctor

Completion functor for the color channel.

GraphicsFormat colorFormat

The pixel format to capture in.

Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> depthFunctor

Completion functor for the depth channel.

GraphicsFormat depthFormat

The pixel format to capture in.

Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> motionFunctor

Completion functor for the motion vectors channel.

GraphicsFormat motionFormat

The pixel format to capture in.

bool flipY

Whether or not to flip the image vertically.

Returns
Type Description
AsyncRequest<CaptureCamera.CaptureState>

AsyncRequest<CaptureState>

Capture(Camera, Func<AsyncRequest<CaptureState>, Result>, GraphicsFormat, Func<AsyncRequest<CaptureState>, Result>, GraphicsFormat, Func<AsyncRequest<CaptureState>, Result>, GraphicsFormat, Func<AsyncRequest<CaptureState>, Result>, GraphicsFormat, ForceFlip, RenderTextureReadWrite)

Main Capture entrypoint.

Declaration
public static AsyncRequest<CaptureCamera.CaptureState> Capture(Camera camera, Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> colorFunctor = null, GraphicsFormat colorFormat = GraphicsFormat.R8G8B8A8_UNorm, Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> depthFunctor = null, GraphicsFormat depthFormat = GraphicsFormat.R8G8B8A8_UNorm, Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> normalFunctor = null, GraphicsFormat normalFormat = GraphicsFormat.R8G8B8A8_UNorm, Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> motionFunctor = null, GraphicsFormat motionFormat = GraphicsFormat.R8G8B8A8_UNorm, ForceFlip forceFlip = ForceFlip.None, RenderTextureReadWrite readWrite = RenderTextureReadWrite.Default)
Parameters
Type Name Description
Camera camera

The Camera to capture data from.

Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> colorFunctor

Completion functor for the color channel.

GraphicsFormat colorFormat

The pixel format to capture in.

Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> depthFunctor

Completion functor for the depth channel.

GraphicsFormat depthFormat

The pixel format to capture in.

Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> normalFunctor
GraphicsFormat normalFormat
Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> motionFunctor

Completion functor for the motion vectors channel.

GraphicsFormat motionFormat

The pixel format to capture in.

ForceFlip forceFlip
RenderTextureReadWrite readWrite

Specify the desired color space conversion. If Default, then will be set to sRGB for SRP Color channel.

Returns
Type Description
AsyncRequest<CaptureCamera.CaptureState>

AsyncRequest<CaptureState>

CaptureColorAndDepthToFile(Camera, GraphicsFormat, string, ImageFormat, GraphicsFormat, string, ImageFormat)

Captures a camera render and writes out the color and depth channels to a file.

Declaration
public static AsyncRequest<CaptureCamera.CaptureState> CaptureColorAndDepthToFile(Camera camera, GraphicsFormat colorFormat = GraphicsFormat.R8G8B8A8_UNorm, string colorPath = null, CaptureImageEncoder.ImageFormat colorImageFormat = ImageFormat.Jpg, GraphicsFormat depthFormat = GraphicsFormat.R16_UNorm, string depthPath = null, CaptureImageEncoder.ImageFormat depthImageFormat = ImageFormat.Raw)
Parameters
Type Name Description
Camera camera

The Camera to capture data from.

GraphicsFormat colorFormat

The pixel format to capture in.

string colorPath

The location of the file to write out.

CaptureImageEncoder.ImageFormat colorImageFormat

The image format to write the data out in.

GraphicsFormat depthFormat

The pixel format to capture in.

string depthPath

The location of the file to write out.

CaptureImageEncoder.ImageFormat depthImageFormat

The image format to write the data out in.

Returns
Type Description
AsyncRequest<CaptureCamera.CaptureState>

AsyncRequest<CaptureState>

CaptureColorToFile(Camera, GraphicsFormat, string, ImageFormat)

Captures a camera render and writes out the color channel to a file.

Declaration
public static AsyncRequest<CaptureCamera.CaptureState> CaptureColorToFile(Camera camera, GraphicsFormat colorFormat, string colorPath, CaptureImageEncoder.ImageFormat colorImageFormat = ImageFormat.Jpg)
Parameters
Type Name Description
Camera camera

The Camera to capture data from.

GraphicsFormat colorFormat

The color pixel format to capture in.

string colorPath

The location of the file to write out.

CaptureImageEncoder.ImageFormat colorImageFormat

The image format to write the data out in.

Returns
Type Description
AsyncRequest<CaptureCamera.CaptureState>

AsyncRequest<CaptureState>

CaptureDepthToFile(Camera, GraphicsFormat, string, ImageFormat)

Captures a camera render and writes out the depth channel to a file.

Declaration
public static AsyncRequest<CaptureCamera.CaptureState> CaptureDepthToFile(Camera camera, GraphicsFormat depthFormat, string depthPath, CaptureImageEncoder.ImageFormat depthImageFormat = ImageFormat.Raw)
Parameters
Type Name Description
Camera camera

The Camera to capture data from.

GraphicsFormat depthFormat

The pixel format to capture in.

string depthPath

The location of the file to write out.

CaptureImageEncoder.ImageFormat depthImageFormat

The image format to write the data out in.

Returns
Type Description
AsyncRequest<CaptureCamera.CaptureState>

AsyncRequest<CaptureState>

SelectShaderVariantForChannel(Channel, GraphicsFormat)

Declaration
public static Material SelectShaderVariantForChannel(CaptureCamera.Channel channel, GraphicsFormat format)
Parameters
Type Name Description
CaptureCamera.Channel channel
GraphicsFormat format
Returns
Type Description
Material

SetupCaptureRequest(AsyncRequest<CaptureState>, Channel, Camera, GraphicsFormat, Func<AsyncRequest<CaptureState>, Result>, ForceFlip, RenderTextureReadWrite)

Setup a capture request for a channel. Once completed, the functor will be called with the channel data, in the format requested.

Declaration
public static void SetupCaptureRequest(AsyncRequest<CaptureCamera.CaptureState> request, CaptureCamera.Channel channel, Camera camera, GraphicsFormat format, Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> functor, ForceFlip forceFlipY, RenderTextureReadWrite readWrite = RenderTextureReadWrite.Default)
Parameters
Type Name Description
AsyncRequest<CaptureCamera.CaptureState> request

AsyncRequest to enqueue readbacks to. When all are completed, the request is marked completed.

CaptureCamera.Channel channel

The channel to capture data from (color, depth etc.)

Camera camera

The Camera to capture data from.

GraphicsFormat format

The graphics format you want the data to be in.

Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> functor

The completion functor to call with the data.

ForceFlip forceFlipY

Flags allowing you to force flipY for arbitrary channels.

RenderTextureReadWrite readWrite

Specify the desired color space conversion. If Default, then will be set to sRGB for SRP Color channel.

SetupCaptureRequestCommandBufferForChannel(AsyncRequest<CaptureState>, Channel, Camera, CommandBuffer, RenderTargetIdentifier, Material, GraphicsFormat, ForceFlip, RenderTextureReadWrite, ReadbackCompletionDelegate)

Setup a CommandBuffer for capturing from a channel.

Declaration
public static void SetupCaptureRequestCommandBufferForChannel(AsyncRequest<CaptureCamera.CaptureState> request, CaptureCamera.Channel channel, Camera camera, CommandBuffer commandBuffer, RenderTargetIdentifier rtid, Material material, GraphicsFormat format, ForceFlip forceFlipY, RenderTextureReadWrite readWrite, CaptureCamera.ReadbackCompletionDelegate completion)
Parameters
Type Name Description
AsyncRequest<CaptureCamera.CaptureState> request

AsyncRequest to enqueue readbacks to. When all are completed, the request is marked completed.

CaptureCamera.Channel channel

The channel to capture data from (color, depth etc.)

Camera camera

The Camera to capture data from.

CommandBuffer commandBuffer

The command buffer to populate. If null, a command buffer will be allocated from a pool.

RenderTargetIdentifier rtid

The render target identifier to capture. If default(RenderTargetIdentifier) then readback will occur from either the Camera.targetTexture or the back buffer.

Material material

Material to use when blitting. If null, then no blit will occur. Use by depth to copy from depth buffer to color buffer, but could be useful elsewhere as well.

GraphicsFormat format

The graphics format you want the data to be in.

ForceFlip forceFlipY

Flags allowing you to force flipY for arbitrary channels.

RenderTextureReadWrite readWrite

Specify the desired color space conversion. If Default, then will be set to sRGB for SRP Color channel.

CaptureCamera.ReadbackCompletionDelegate completion

The completion functor to call with the data.

ShouldFlipY(Camera, Channel, ForceFlip, bool)

Check if for the given rendering pipeline there is a need to flip Y during readback.

Declaration
public static bool ShouldFlipY(Camera camera, CaptureCamera.Channel channel, ForceFlip forceFlipY, bool usePassedInRenderTargetId)
Parameters
Type Name Description
Camera camera

Camera from which the readback is being performed.

CaptureCamera.Channel channel

Channel which the readback is being performed for.

ForceFlip forceFlipY

Override the default to either force flip or force not flip, or neither.

bool usePassedInRenderTargetId

When we are using a passed in rtid, then we don't need to flip.

Returns
Type Description
bool

A boolean indicating if the flip is required.

ValidateRequestParameters(AsyncRequest<CaptureState>)

Declaration
public static void ValidateRequestParameters(AsyncRequest<CaptureCamera.CaptureState> request)
Parameters
Type Name Description
AsyncRequest<CaptureCamera.CaptureState> request
In This Article
Back to top
Copyright © 2026 Unity Technologies — Trademarks and terms of use
  • Legal
  • Privacy Policy
  • Cookie Policy
  • Do Not Sell or Share My Personal Information