Search Unity

Controlling DOF with C# on Post Processing Stack v2?

Discussion in 'General Graphics' started by unfungmz, Jan 27, 2019.

  1. unfungmz

    unfungmz

    Joined:
    Jul 29, 2017
    Posts:
    162
    Any way to control depth of field parameters in runtime via code (post processing v2). I found some code, but I'm getting errors trying to set ---

    PostProcessVolume volume = Cam.GetComponent<PostProcessVolume>();
    DepthOfField MyDOF;

    volume.profile.TryGetSettings(out MyDOF);
    MyDOF.focusDistance = 1.0f;

    error CS0029: Cannot implicitly convert type `float' to `UnityEngine.Rendering.PostProcessing.FloatParameter'
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    10,344
unityunity