(2020.2.7)(URP) I’m trying to make a dynamic depth of field effect. I have not imported any postprocessing assets from the package manager instead im using the global volume component on an empty game object. I have a volume profile linked to it which has a depth of field override which is set to the bokeh mode.
I made a new script and attached it to the camera
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
public class DepthOfField : MonoBehaviour
{
DepthOfField comp;
public Volume volume;
void Start()
{
volume = gameObject.GetComponent<Volume>();
volume.profile.TryGet<DepthOfField>(out comp);
}
}
I get an error on
volume.profile.TryGet(out comp);
Which says
The type ‘DepthOfField’ cannot be used as a type parameter ‘T’ in the generic type or method ‘VolumeProfile.TryGet(out T)’. There is no implicit reference conversion from ‘DepthOfField’ to ‘UnityEngine.Rendering.VolumeComponent’.
Please Help!