Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Any way to get and change current Post Process profile via script?

Discussion in 'Scripting' started by janikboss, Aug 1, 2020.

  1. janikboss

    janikboss

    Joined:
    Jun 4, 2017
    Posts:
    5
    Hi, guys!

    I have been struggling to find a way to get and change current Post Process profile via script.

    I have 2 profiles and what I basically want to do, is to change the current to the other one when a certain key is pressed and then check which profile is currently in use to change it back to the other one.

    So is there any way? I am sure there is, but I am having a hard time finding it and putting my code together.

    Thanks a lot!
     
  2. Terraya

    Terraya

    Joined:
    Mar 8, 2018
    Posts:
    646
    here you go:

    Code (CSharp):
    1. using UnityEngine.Rendering;
    2.  
    3. public Volume postProcessing;
    4. postProcessing.profile <---

    and there you can modify its further data :)
     
    janikboss likes this.
  3. janikboss

    janikboss

    Joined:
    Jun 4, 2017
    Posts:
    5
    Thank you! I eventually got this working this way:

    Code (CSharp):
    1. void ChangeProfiles() // When function is called, profiles are switched
    2.     {
    3.         if (volume.profile == sceneInspectingProfile)
    4.         {
    5.             volume.profile = normalProfile;
    6.         }
    7.         else
    8.         {
    9.             volume.profile = sceneInspectingProfile;
    10.         }
    11.     }
    And then calling the function when I needed to.

    Stay safe!