I try do do dynamic depth of field using Post Processing Stack v2, but i can’t acces Depth of Field Focus Distance through script. I don’t know how te set it’s value, I can’t find any answer in internet, and I can’t find answer in PPS v2 documentation.
Working code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;
public class DepthOfFieldController : MonoBehaviour
{
private PostProcessVolume postProcessVolume;
void Start()
{
postProcessVolume = GetComponent<PostProcessVolume>();
}
// Update is called once per frame
void Update()
{
if (postProcessVolume)
{
DepthOfField pr;
if (postProcessVolume.sharedProfile.TryGetSettings<DepthOfField>(out pr))
{
Debug.Log(pr.focusDistance.value);
}
}
}
}