Skip to content

Commit

Permalink
DOCG-4786 Fix code sample
Browse files Browse the repository at this point in the history
  • Loading branch information
markg-unity committed Nov 28, 2024
1 parent 0ad4df7 commit b84a1c0
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions com.unity.postprocessing/Documentation~/Manipulating-the-Stack.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,41 @@ This guide explains how to modify a post-processing script to create time-based
Use the `QuickVolume` method to quickly spawn new volumes in the scene, to create time-based events or temporary states:

```csharp
[
public PostProcessVolume QuickVolume(int layer, float priority, params PostProcessEffectSettings[] settings)
]
```
The following example demonstrates how to use a script to create a pulsating vignette effect:

```csharp
[
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;

public class VignettePulse : MonoBehaviour
{
PostProcessVolume m_Volume;
Vignette m_Vignette
void Start()
PostProcessVolume m_Volume;
Vignette m_Vignette;

void Start()
{
// Create an instance of a vignette
m_Vignette = ScriptableObject.CreateInstance<Vignette>();
m_Vignette.enabled.Override(true);
m_Vignette.intensity.Override(1f);
m_Vignette = ScriptableObject.CreateInstance<Vignette>();
m_Vignette.enabled.Override(true);
m_Vignette.intensity.Override(1f);

// Use the QuickVolume method to create a volume with a priority of 100, and assign the vignette to this volume
m_Volume = PostProcessManager.instance.QuickVolume(gameObject.layer, 100f, m_Vignette);
void Update()
m_Volume = PostProcessManager.instance.QuickVolume(gameObject.layer, 100f, m_Vignette);
}

void Update()
{
// Change vignette intensity using a sinus curve
m_Vignette.intensity.value = Mathf.Sin(Time.realtimeSinceStartup);
m_Vignette.intensity.value = Mathf.Sin(Time.realtimeSinceStartup);
}
void OnDestroy()

void OnDestroy()
{
RuntimeUtilities.DestroyVolume(m_Volume, true, true);
RuntimeUtilities.DestroyVolume(m_Volume, true, true);
}

}
```

Expand Down

0 comments on commit b84a1c0

Please sign in to comment.