- Home /
 
 
               Question by 
               MItCHeL_PL · Apr 11, 2019 at 09:00 PM · 
                scripting problemdynamicpost processingdepth of field  
              
 
              How to acces Depth Of Field Focus Distance through script in Post Processing Stack V2.
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.
               Comment
              
 
               
              Answer by MItCHeL_PL · Apr 15, 2019 at 03:02 PM
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);
             }
         }
     }
 }
 
              Your answer