Class DynamicResolutionHandler
The class responsible to handle dynamic resolution.
Namespace: UnityEngine.Rendering
Syntax
public class DynamicResolutionHandler : object
Properties
filter
The filter that is used to upscale the rendering result to the native resolution.
Declaration
public DynamicResUpscaleFilter filter { get; set; }
Property Value
Type | Description |
---|---|
DynamicResUpscaleFilter |
finalViewport
The viewport of the final buffer. This is likely the resolution the dynamic resolution starts from before any scaling. Note this is NOT the target resolution the rendering will happen in but the resolution the scaled rendered result will be upscaled to.
Declaration
public Vector2Int finalViewport { get; set; }
Property Value
Type | Description |
---|---|
Vector2Int |
instance
Get the instance of the global dynamic resolution handler.
Declaration
public static DynamicResolutionHandler instance { get; }
Property Value
Type | Description |
---|---|
DynamicResolutionHandler |
Methods
ApplyScalesOnSize(Vector2Int)
Applies to the passed size the scale imposed by the dynamic resolution system. Note: this function is pure (has no side effects), this function does not cache the pre-scale size
Declaration
public Vector2Int ApplyScalesOnSize(Vector2Int size)
Parameters
Type | Name | Description |
---|---|---|
Vector2Int | size | The size to apply the scaling |
Returns
Type | Description |
---|---|
Vector2Int | The parameter size scaled by the dynamic resolution system. |
ClearSelectedCamera()
Will clear the currently used camera. Use this function to restore the default instance when UpdateAndUseCamera is called.
Declaration
public static void ClearSelectedCamera()
DynamicResolutionEnabled()
Identifies whether dynamic resolution is enabled and scaling the render targets.
Declaration
public bool DynamicResolutionEnabled()
Returns
Type | Description |
---|---|
Boolean | True: Dynamic resolution is enabled. |
ForceSoftwareFallback()
Forces software fallback for dynamic resolution. Needs to be called in case Hardware dynamic resolution is requested by the user, but not supported by the platform.
Declaration
public void ForceSoftwareFallback()
GetCurrentScale()
Returns the scale that is currently applied by the dynamic resolution system.
Declaration
public float GetCurrentScale()
Returns
Type | Description |
---|---|
Single | The scale that is currently applied by the dynamic resolution system. |
GetLastScaledSize()
Returns the latest scaled size that has been produced by GetScaledSize.
Declaration
public Vector2Int GetLastScaledSize()
Returns
Type | Description |
---|---|
Vector2Int | The latest scaled size that has been produced by GetScaledSize. |
GetResolvedScale()
Declaration
public Vector2 GetResolvedScale()
Returns
Type | Description |
---|---|
Vector2 |
GetScaledSize(Vector2Int)
Applies to the passed size the scale imposed by the dynamic resolution system. Note: this function has the side effect of caching the last scale size.
Declaration
public Vector2Int GetScaledSize(Vector2Int size)
Parameters
Type | Name | Description |
---|---|---|
Vector2Int | size | The starting size of the render target that will be scaled by dynamic resolution. |
Returns
Type | Description |
---|---|
Vector2Int | The parameter size scaled by the dynamic resolution system. |
HardwareDynamicResIsEnabled()
Determines whether hardware dynamic resolution is enabled or not.
Declaration
public bool HardwareDynamicResIsEnabled()
Returns
Type | Description |
---|---|
Boolean | True: Hardware dynamic resolution is enabled |
RequestsHardwareDynamicResolution()
Identifies whether hardware dynamic resolution has been requested and is going to be used.
Declaration
public bool RequestsHardwareDynamicResolution()
Returns
Type | Description |
---|---|
Boolean | True: Hardware dynamic resolution is requested by user and software fallback has not been forced |
SetCurrentCameraRequest(Boolean)
Set whether the camera that is currently processed by the pipeline has requested dynamic resolution or not.
Declaration
public void SetCurrentCameraRequest(bool cameraRequest)
Parameters
Type | Name | Description |
---|---|---|
Boolean | cameraRequest | Determines whether the camera has requested dynamic resolution or not. |
SetDynamicResScaler(PerformDynamicRes, DynamicResScalePolicyType)
Set the scaler method used to drive dynamic resolution.
Declaration
public static void SetDynamicResScaler(PerformDynamicRes scaler, DynamicResScalePolicyType scalerType = DynamicResScalePolicyType.ReturnsMinMaxLerpFactor)
Parameters
Type | Name | Description |
---|---|---|
PerformDynamicRes | scaler | The delegate used to determine the resolution percentage used by the dynamic resolution system. |
DynamicResScalePolicyType | scalerType | The type of scaler that is used, this is used to indicate the return type of the scaler to the dynamic resolution system. |
SoftwareDynamicResIsEnabled()
Determines whether software dynamic resolution is enabled or not.
Declaration
public bool SoftwareDynamicResIsEnabled()
Returns
Type | Description |
---|---|
Boolean | True: Software dynamic resolution is enabled |
Update(GlobalDynamicResolutionSettings, Action)
Update the state of the dynamic resolution system.
Declaration
public void Update(GlobalDynamicResolutionSettings settings, Action OnResolutionChange = null)
Parameters
Type | Name | Description |
---|---|---|
GlobalDynamicResolutionSettings | settings | The settings that are to be used by the dynamic resolution system. |
Action | OnResolutionChange | An action that will be called every time the dynamic resolution system triggers a change in resolution. |
UpdateAndUseCamera(Camera, Nullable<GlobalDynamicResolutionSettings>, Action)
Declaration
public static void UpdateAndUseCamera(Camera camera, GlobalDynamicResolutionSettings? settings = null, Action OnResolutionChange = null)
Parameters
Type | Name | Description |
---|---|---|
Camera | camera | |
Nullable<GlobalDynamicResolutionSettings> | settings | |
Action | OnResolutionChange |