So, I am using Post Processing to create a vignette for my game. Now I want to have a speed effect, so when I collect a potion, it turns the vignette green or something. to do this, I use the code:
using UnityEngine;
using System.Collections;
using UnityEngine.Rendering.PostProcessing;
public class ControlPostProcessing : MonoBehaviour
{
public PostProcessVolume vol;
public ColorParameter vignetterColor;
public Vignette vignette;
void Start()
{
vignetterColor.value = new Color(0f, 0f, 0f);
vol.profile.TryGetSettings(out vignette);
}
void Update()
{
vignette.color = vignetterColor;
if(Input.GetKey(KeyCode.JoystickButton3)) StartCoroutine(SpeedEffect());
}
IEnumerator SpeedEffect()
{
vignetterColor.value = new Color(0f, 1f, 0f);
yield return new WaitForSeconds(10);
vignetterColor.value = new Color(0f, 0f, 0f);
}
}
This works, or rather in the inspector I see that it changes the vignette's color. Although, it always disables the color.
While in the scene:
![alt text][1]
while playing:
![alt text][2]
[1]: /storage/temp/164820-vig.png
[2]: /storage/temp/164821-2vig.png
↧