Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Unity 2019.3 b12 change post effects at runtime

Discussion in '2019.3 Beta' started by EddieChristian, Nov 25, 2019.

  1. EddieChristian

    EddieChristian

    Joined:
    Oct 9, 2012
    Posts:
    725
    I am trying to access the Vignette Override and can find no way to do it. My Script has these in it:

    Code (CSharp):
    1. using UnityEngine.Rendering.HighDefinition;
    2.  
    3.     public GameObject PostObject;
    4.     public Vignette ActivePostVignette;
    5.  
    6.  


    Code (CSharp):
    1.    void FindPostVFX() // WE CREATED THIS FUNCTION
    2.     {
    3.  
    4.         PostObject = GameObject.FindGameObjectWithTag("POST");
    5.  
    6.         ActivePostVignette = PostObject.GetComponent<Vignette>();
    7.  
    8.  
    9. }
    And in the compiler this shows no errors:

    Code (CSharp):
    1.         ActivePostVignette.intensity.value = StoreCurrent + WOUNDS * 0.001f;
    But when I run it in the compiler "ActivePostVignette" is empty. It's not finding the Vignette Override. And if I try to access the "Volume" Component, it tells me it doesn't exist in the namespace. What am I missing???
     
    Last edited: Nov 25, 2019
  2. EddieChristian

    EddieChristian

    Joined:
    Oct 9, 2012
    Posts:
    725
    Ok I tried changing the post effect through the profile and every other method that is currently online. How in the HECK do you modify these post effects in code?????????
     
  3. Refeas

    Refeas

    Joined:
    Nov 8, 2016
    Posts:
    192
    You can try it like this:
    Code (CSharp):
    1. Volume volume;
    2. VolumeProfile profile;
    3. Vignette vignette;
    4.  
    5. void Awake() {
    6.     volume = GameObject.FindGameObjectWithTag("POST").GetComponent<Volume>();
    7.     volumeProfile = volume.profile;
    8.     volumeProfile.TryGet(out vignette);
    9. }
     
  4. EddieChristian

    EddieChristian

    Joined:
    Oct 9, 2012
    Posts:
    725
    Actually I did try that but for some reason The Vignette it gets is marked as a clone and changes to it don't affect the scene.
     
  5. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    589
    It should work if your profile has already a vignette setting attached. This scripts assume you have already the reference of the volume profil you want to change.

    Code (CSharp):
    1. if (globalVolumeProfile != null)
    2. {
    3. if (globalVolumeProfile.TryGet<Vignette>(out Vignette vignette))
    4. {
    5. vignette.intensity.value = 0.5f;
    6. }
    7. }