Search Unity

Accessing Post Processing in script 2019.4

Discussion in 'Scripting' started by Jassucks, Jul 7, 2020.

  1. Jassucks

    Jassucks

    Joined:
    Sep 16, 2018
    Posts:
    5
    Hi!
    I'm fairly new to coding and Unity and I know this has been asked a lot but I just can't seem to get it to work no matter what I try. I'm using Unity 2019.4 and the Univeral Render Pipeline.
    Just trying to access some Post Processing components such as bloom during runtime.

    I get an error on TryGet<Bloom> that says:
    "The type 'UnityEngine.Rendering.PostProcessing.Bloom' cannot be used as a type parameter 'T' in the generic type or method 'VolumeProfile.TryGet<T>(out T)'. There is no implicit reference conversion from 'UnityEngine.Rendering.PostProcessing.Bloom' to 'UnityEngine.Rendering.VolumeComponent'."

    The code is mainly copied from another answer but clearly I'm missing something. Any idea how to fix this?

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Rendering;
    3. using UnityEngine.Rendering.PostProcessing;
    4.  
    5.  
    6. public class PostProcessing : MonoBehaviour
    7. {
    8.     //public PostProcessVolume volume;
    9.  
    10.     private Bloom _Bloom;
    11.  
    12.  
    13.     // Start is called before the first frame update
    14.     void Start()
    15.     {
    16.         Volume volume = GetComponent<Volume>();
    17.  
    18.         Bloom tempB;
    19.  
    20.        if (volume.profile.TryGet<Bloom>(out tempB))
    21.         {
    22.             _Bloom = tempB;
    23.         }
    24.     }
    25. }
    26.  
     
    Last edited: Jul 7, 2020
  2. Diamond32

    Diamond32

    Joined:
    Oct 28, 2017
    Posts:
    1
    Hey, I had same problem. Instead of using:
    Code (CSharp):
    1. using UnityEngine.Rendering.PostProcessing;
    Try this:
    Code (CSharp):
    1. using UnityEngine.Rendering.Universal;
     
  3. SandeepaAthukoralaUnity

    SandeepaAthukoralaUnity

    Joined:
    Sep 24, 2022
    Posts:
    1
    You saved my day dear thank you