Question by
PlayouGames · Nov 25, 2021 at 05:10 AM ·
c#post processingpost effects
Edit Post Processing
Hello,
I would like to trigger post processing to change the scene color from normal to black and white. However this code does not seem to work. Im using an event system to trigger it after the player has reached a certain point in the game.
Thanks for the help
using UnityEngine;
using System.Collections;
using MoreMountains.Tools;
using UnityEngine.Rendering.PostProcessing;
namespace MoreMountains.InfiniteRunnerEngine
{
public class ExampleScenario : ScenarioManager
{
public DistanceSpawner HillSpawner;
public DistanceSpawner MushroomSpawner;
public PostProcessVolume editPostProcess;
private ColorGrading blackAndWhite;
protected override void Scenario()
{
AddScoreEvent(200f, () => SwitchToNightMode());
/*AddScoreEvent(220f, () => SwitchToNothing());
AddScoreEvent(250f, ()=> SwitchToMushroomSpawner());
AddScoreEvent(330f, () => SwitchToNothing());
AddScoreEvent(350f, () => SwitchToHillSpawner());
AddScoreEvent(430f, () => SwitchToNothing());
AddScoreEvent(450f, () => SwitchToMushroomSpawner());
AddScoreEvent(510f, () => SwitchToNothing());
AddScoreEvent(550f, () => SwitchToHillSpawner());*/
}
protected virtual void SwitchToHillSpawner()
{
HillSpawner.gameObject.GetComponent<DistanceSpawner>().Spawning = true;
MushroomSpawner.gameObject.gameObject.GetComponent<DistanceSpawner>().Spawning = false;
}
protected virtual void SwitchToNothing()
{
HillSpawner.gameObject.GetComponent<DistanceSpawner>().Spawning = false;
MushroomSpawner.gameObject.gameObject.GetComponent<DistanceSpawner>().Spawning = false;
}
protected virtual void SwitchToMushroomSpawner()
{
HillSpawner.gameObject.GetComponent<DistanceSpawner>().Spawning = false;
MushroomSpawner.gameObject.gameObject.GetComponent<DistanceSpawner>().Spawning = true;
}
protected virtual void SwitchToNightMode()
{
blackAndWhite.saturation.value = -100f;
}
}
}
Comment
Your answer
Follow this Question
Related Questions
How edit Volume Profile values via script? 0 Answers
[HELP] Post Processing Stack v2 + Cinemachine - How to track focus on target like PPSv1? 0 Answers
why the effects of the Post Processing stack do not activate through an if-statement 0 Answers
Unable to switch Post-Process Layer to PostProcessing LayerMask 1 Answer
built in render pipeline custom post-processing profile? 0 Answers