docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class CameraExtensions

    Contains extension methods for Camera class.

    Inheritance
    object
    CameraExtensions
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.Rendering.Universal
    Assembly: Unity.RenderPipelines.Universal.Runtime.dll
    Syntax
    public static class CameraExtensions
    Remarks

    This class adds extension methods to the Camera class. It provides helper methods for retrieving the UniversalAdditionalCameraData, and getting and setting volume update settings.

    Examples

    This sample code shows how to get UniversalAdditionalCameraData and manually update the VolumeStack at runtime.

    using UnityEngine;
    using UnityEngine.Rendering.Universal;
    

    public class UpdateVolumeStackOnCamera : MonoBehaviour { // Reference to the camera component [SerializeField] private Camera cameraToUpdate;

    // Toggle to make the script update the volume framework
    [SerializeField] private bool shouldUpdateVolumeFramework;
    
    
    // Update is called once per frame
    private void Update()
    {
        // Leave if the volume framework shouldn't be updated
        if (!shouldUpdateVolumeFramework)
            return;
    
        // Mark that we shouldn't update the volume framework in the next frame
        shouldUpdateVolumeFramework = false;
    
        // Check if we have a reference to the camera
        if (cameraToUpdate == null)
        {
            Debug.LogError("UpdateVolumeStackOnCamera.Update(): cameraToUpdate has not been assigned.");
            return;
        }
    
        // Make the camera use the ViaScripting mode so the volume framework only updates when the script calls UpdateVolumeStack().
        VolumeFrameworkUpdateMode volumeFrameworkUpdateMode = cameraToUpdate.GetVolumeFrameworkUpdateMode();
        if (volumeFrameworkUpdateMode != VolumeFrameworkUpdateMode.ViaScripting)
        {
            cameraToUpdate.SetVolumeFrameworkUpdateMode(VolumeFrameworkUpdateMode.ViaScripting);
        }
    
        // Update the volume framework
        cameraToUpdate.UpdateVolumeStack();
    }
    

    }

    Methods

    DestroyVolumeStack(Camera)

    Destroys the VolumeStack for this camera.

    Declaration
    public static void DestroyVolumeStack(this Camera camera)
    Parameters
    Type Name Description
    Camera camera

    The Camera to use for destroying the VolumeStack.

    Remarks

    Each camera can hold a local VolumeStack, which contains the state of a volume blending update. A global stack is available by default in VolumeManager but you can also create your own using CreateStack() if you need to update the manager with specific settings and store the results for later use.

    See Also
    Camera
    UniversalAdditionalCameraData
    VolumeFrameworkUpdateMode
    LayerMask
    Transform
    VolumeManager
    VolumeStack

    DestroyVolumeStack(Camera, UniversalAdditionalCameraData)

    Destroys the VolumeStack for this camera.

    Declaration
    public static void DestroyVolumeStack(this Camera camera, UniversalAdditionalCameraData cameraData)
    Parameters
    Type Name Description
    Camera camera

    The Camera to use for destroying the VolumeStack.

    UniversalAdditionalCameraData cameraData

    The UniversalAdditionalCameraData component on the camera that should be used.

    Remarks

    Each camera can hold a local VolumeStack, which contains the state of a Volume blending update. A global stack is available by default in VolumeManager but you can also create your own using CreateStack() if you need to update the manager with specific settings and store the results for later use.

    See Also
    Camera
    UniversalAdditionalCameraData
    VolumeFrameworkUpdateMode
    LayerMask
    Transform
    VolumeManager
    VolumeStack

    GetUniversalAdditionalCameraData(Camera)

    Provides additional camera data component that's attached to the given camera.

    Declaration
    public static UniversalAdditionalCameraData GetUniversalAdditionalCameraData(this Camera camera)
    Parameters
    Type Name Description
    Camera camera

    The Camera to use for getting the UniversalAdditionalCameraData.

    Returns
    Type Description
    UniversalAdditionalCameraData

    The UniversalAdditionalCameraData for this camera.

    Remarks

    The Universal Render Pipeline exposes various additional rendering data in a separate component named 'UniversalAdditionalCameraData'. This method returns the additional data component for the given camera or creates one if it doesn't exist yet.

    See Also
    Camera
    UniversalAdditionalCameraData
    VolumeFrameworkUpdateMode
    LayerMask
    Transform
    VolumeManager
    VolumeStack

    GetVolumeFrameworkUpdateMode(Camera)

    Returns the update frequency for the volume framework associated with the camera.

    Declaration
    public static VolumeFrameworkUpdateMode GetVolumeFrameworkUpdateMode(this Camera camera)
    Parameters
    Type Name Description
    Camera camera

    The Camera to use for getting the VolumeFrameworkUpdateMode.

    Returns
    Type Description
    VolumeFrameworkUpdateMode

    The VolumeFrameworkUpdateMode set on this camera.

    Remarks

    Each camera can be set to update the volume framework in each frame, via scripting or using the setting set in the UniversalRenderPipelineAsset. This method returns the setting for the given camera.

    See Also
    Camera
    UniversalAdditionalCameraData
    VolumeFrameworkUpdateMode
    LayerMask
    Transform
    VolumeManager
    VolumeStack

    SetVolumeFrameworkUpdateMode(Camera, VolumeFrameworkUpdateMode)

    Sets the update frequency for the volume framework associated with the camera.

    Declaration
    public static void SetVolumeFrameworkUpdateMode(this Camera camera, VolumeFrameworkUpdateMode mode)
    Parameters
    Type Name Description
    Camera camera

    The Camera to use for setting the VolumeStack.

    VolumeFrameworkUpdateMode mode

    The VolumeFrameworkUpdateMode value to set.

    Remarks

    Each camera can be set to update the volume framework in each frame, via scripting or using the setting set in the UniversalRenderPipelineAsset. This method is used to change that setting for the given camera.

    See Also
    Camera
    UniversalAdditionalCameraData
    VolumeFrameworkUpdateMode
    LayerMask
    Transform
    VolumeManager
    VolumeStack

    UpdateVolumeStack(Camera)

    Updates the volume stack for this camera.

    Declaration
    public static void UpdateVolumeStack(this Camera camera)
    Parameters
    Type Name Description
    Camera camera

    The Camera to use for updating the VolumeStack.

    Remarks

    This method only updates the VolumeStack when the camera has ViaScripting enabled or if the camera is set to UsePipelineSettings and the Render Pipeline Asset is set to ViaScripting.

    See Also
    Camera
    UniversalAdditionalCameraData
    VolumeFrameworkUpdateMode
    LayerMask
    Transform
    VolumeManager
    VolumeStack

    UpdateVolumeStack(Camera, UniversalAdditionalCameraData)

    Updates the volume stack for this camera.

    Declaration
    public static void UpdateVolumeStack(this Camera camera, UniversalAdditionalCameraData cameraData)
    Parameters
    Type Name Description
    Camera camera

    The Camera to use for updating the VolumeStack.

    UniversalAdditionalCameraData cameraData

    The UniversalAdditionalCameraData component on the camera that should be updated.

    Remarks

    This method only updates the VolumeStack when the camera has ViaScripting enabled or if the camera is set to UsePipelineSettings and the Render Pipeline Asset is set to ViaScripting.

    See Also
    Camera
    UniversalAdditionalCameraData
    VolumeFrameworkUpdateMode
    LayerMask
    Transform
    VolumeManager
    VolumeStack

    See Also

    Camera
    UniversalAdditionalCameraData
    VolumeFrameworkUpdateMode
    LayerMask
    Transform
    VolumeManager
    VolumeStack
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)