Class CameraExtensions
Contains extension methods for Camera class.
Inherited Members
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 Universal
Examples
This sample code shows how to get Universal
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 Unity
Declaration
public static void DestroyVolumeStack(this Camera camera)
Parameters
Type | Name | Description |
---|---|---|
Camera | camera | The Camera to use for destroying the Unity |
Remarks
Each camera can hold a local Unity
See Also
DestroyVolumeStack(Camera, UniversalAdditionalCameraData)
Destroys the Unity
Declaration
public static void DestroyVolumeStack(this Camera camera, UniversalAdditionalCameraData cameraData)
Parameters
Type | Name | Description |
---|---|---|
Camera | camera | The Camera to use for destroying the Unity |
Universal |
cameraData | The Universal |
Remarks
Each camera can hold a local Unity
See Also
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 Universal |
Returns
Type | Description |
---|---|
Universal |
The Universal |
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
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 Volume |
Returns
Type | Description |
---|---|
Volume |
The Volume |
Remarks
Each camera can be set to update the volume framework in each frame, via scripting or using the setting
set in the Universal
See Also
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 Unity |
Volume |
mode | The Volume |
Remarks
Each camera can be set to update the volume framework in each frame, via scripting or using the setting
set in the Universal
See Also
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 Unity |
Remarks
This method only updates the UnityViaScripting
enabled or if
the camera is set to UsePipelineSettings
and the Render Pipeline Asset is set to ViaScripting
.
See Also
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 Unity |
Universal |
cameraData | The Universal |
Remarks
This method only updates the UnityViaScripting
enabled or if
the camera is set to UsePipelineSettings
and the Render Pipeline Asset is set to ViaScripting
.