[Unity] Access to the PostProcess from script

## [Built-in render pipeline]

<big>1</big>st of all, import [UnityEngine.Rendering.PostProcessing](https://docs.unity3d.com/Packages/com.unity.postprocessing@2.1/api/UnityEngine.Rendering.PostProcessing.html),
and get the [PostProcessVolume](https://docs.unity3d.com/Packages/com.unity.postprocessing@2.1/api/UnityEngine.Rendering.PostProcessing.PostProcessVolume.html).
```cs
using UnityEngine.Rendering.PostProcessing;
```
```cs
    [SerializeField] PostProcessVolume m_vol;
```


<big>2</big>nd of all, get the [PostProcessProfile](https://docs.unity3d.com/Packages/com.unity.postprocessing@2.0/api/UnityEngine.Rendering.PostProcessing.PostProcessProfile.html) and get the effect you want.

```cs
    PostProcessProfile profile = m_vol.profile;
    m_colorGrading = profile.GetSetting<ColorGrading>();
```

<big>3.</big>
and edit parameters.

```PostProcessBuiltinChanger.cs
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;

namespace PostProcessBuiltinChangerDemo
{
    public class PostProcessBuiltinChanger : MonoBehaviour
    {
        [SerializeField] PostProcessVolume m_vol;
        ColorGrading m_colorGrading;

        // Start is called once before the first execution of Update after the MonoBehaviour is created
        void Start()
        {
            PostProcessProfile profile = m_vol.profile;
            m_colorGrading = profile.GetSetting<ColorGrading>();
        }

        // Update is called once per frame
        void Update()
        {
        }

        public void OnSetGamma(float _value)
        {
            Vector4Parameter gamma = m_colorGrading.gamma;
            gamma.value = new Vector4(1f, 1f, 1f, _value);
            m_colorGrading.gamma = gamma;
            Debug.Log("gamma: " + gamma.value);
        }
    }
}
```

|  |  |
|:-:|:-:|
| ![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/59911/26dadc8e-ff40-7a17-5be4-24dbec915355.png) | ![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/59911/5c3c6bea-1b50-2de4-4f04-e49acf6eddcf.png) |




## [Universal render pipeline(URP)]

<big>1</big>st of all, import [UnityEngine.Rendering.Universal](https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@7.0/api/UnityEngine.Rendering.Universal.html),
and get the [UnityEngine.Rendering.Volume](https://docs.unity3d.com/Packages/com.unity.render-pipelines.core@5.9/api/UnityEngine.Rendering.Volume.html).

```cs
using UnityEngine.Rendering.Universal;
```
```cs
    [SerializeField] UnityEngine.Rendering.Volume m_vol;
```

<big>2</big>nd of all, TryGet() the effect.
```cs
    LiftGammaGain m_liftGammaGain
```
```
        m_liftGammaGain = null;
        m_vol.profile.TryGet(out m_liftGammaGain);
```

<big>3</big>.
and edit parameters.

```PostProcessURPChanger.cs
using UnityEngine;
using UnityEngine.Rendering.Universal;

namespace PostProcessURPChangerDemo
{
    public class PostProcessURPChanger : MonoBehaviour
    {
        [SerializeField] UnityEngine.Rendering.Volume m_vol;
        LiftGammaGain m_liftGammaGain;

        // Start is called once before the first execution of Update after the MonoBehaviour is created
        void Start()
        {
            m_liftGammaGain = null;
            m_vol.profile.TryGet(out m_liftGammaGain);
        }

        // Update is called once per frame
        void Update()
        {
        }

        public void OnSetGamma(float _value)
        {
            m_liftGammaGain.gamma.value = new Vector4(1f, 1f, 1f, _value);
        }
    }
}
```
|  |  |
|:-:|:-:|
| ![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/59911/8b488d29-e4d4-f220-8184-60defa99abed.png) | ![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/59911/1f517d52-11a0-2fbb-e849-e751f8501055.png) |