Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

change values of Post Proces Stack V2

Discussion in 'Scripting' started by TokyoWarfareProject, Dec 19, 2018.

  1. TokyoWarfareProject

    TokyoWarfareProject

    Joined:
    Jun 20, 2018
    Posts:
    801
    Hi. I'm strugling seriously with this.

    There is very scarce documentations and the few samples are from v1. I'm surprised there is so few info on this, may be ppl does not use it.

    The thing is that I need to change values of the fx on teh profile, I whant only to change values on the "instance" but It keeps giving me errs despite it seems like the way to go according to the docs.

    this won´t compile, like the BlomRenderer and any other fx seems like not the correct type you would feed the TryGetSettings, but I can´t figure out what else I should put in


    Code (CSharp):
    1.       PostProcessVolume[] fxVols = FindObjectsOfType<PostProcessVolume>();
    2.         foreach (PostProcessVolume  v in fxVols) {
    3.             if (v.isGlobal) {
    4.                 fxvol = v;
    5.                 continue;
    6.             }
    7.         }
    8.  
    9.         BloomRenderer  Settings;
    10.  
    11.         bool test  = fxvol.profile.TryGetSettings<BloomRenderer>(out Settings);
    12.      
    13.         Settings.settings.threshold.value =  1.31f ;
    14.  
     
  2. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,900
  3. TokyoWarfareProject

    TokyoWarfareProject

    Joined:
    Jun 20, 2018
    Posts:
    801
    I tihnk this would work but as you see the profile settings is a list, and I see no way to know at what indexs is an specific effect. I think this is a ridiculously cumbersome way to setting values, it should be like profile.(effect list).settings=modified settings.

    If your profiles have not all the same order this wont work....

    Code (CSharp):
    1.     public sealed class Bloom_V2 : PostProcessEffectSettings{
    2.         public FloatParameter threshold;
    3.     }
    4.  
    5.     void Awake()
    6.     {
    7.        
    8.         PostProcessVolume[] fxVols = FindObjectsOfType<PostProcessVolume>();
    9.         foreach (PostProcessVolume  v in fxVols) {
    10.             if (v.isGlobal) {
    11.                 fxvol = v;
    12.                 continue;
    13.             }
    14.         }
    15.  
    16.         Bloom_V2 Settings;
    17.         fxvol.profile.TryGetSettings<Bloom_V2>(out Settings );              
    18.         Settings.threshold.value=1.31f;
    19.         fxvol.profile.settings[1] = Settings;
    20.  
     
  4. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,900
    Yes, it's called 'artistic freedom'. This is a List of ScriptableObjects and since you can throw your effects on the Postprocessing in any order you wish (almost), it needs to handle it somehow. They do it in the way it's the most performant in run-time. I really don't care if we have a little bit hard time to poke around in edit time from code. It's the nature of tool-development, so your mumbling is misplaced.
     
  5. TokyoWarfareProject

    TokyoWarfareProject

    Joined:
    Jun 20, 2018
    Posts:
    801
    lol, fine TX!