Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Rendering.PostProcessing;  public class VignetteController : MonoBehaviour {     public PostProcessVolume postProcessVolume;     private Vignette vignette;     private float startIntensity;     public float maxIntensity = 0.7f; // You can change this value to your desired maximum intensity     public float decreaseSpeed = 0.5f; // The speed at which the intensity decreases      private void Start()     {         if (postProcessVolume == null)         {             Debug.LogError("Post-Process Volume is not assigned!");             this.enabled = false;             return;         }          // Try to get the Vignette effect from the volume         if (!postProcessVolume.profile.TryGetSettings(out vignette))         {             Debug.LogError("Vignette is not found in the Post-Process Volume!");             this.enabled = false;             return;         }          // Cache the initial intensity         startIntensity = vignette.intensity;     }      public void SetVignetteIntensity(float target)     {         float targetValue = Mathf.Lerp(startIntensity, maxIntensity, target);         if (targetValue < vignette.intensity.value) return;         vignette.intensity.value = targetValue;     }      private void Update()     {         if (vignette.intensity > startIntensity)         {             // Gradually decrease the intensity over time             vignette.intensity.value -= decreaseSpeed * Time.deltaTime;              // Make sure the intensity doesn't go below the initial value             vignette.intensity.value = Mathf.Max(vignette.intensity, startIntensity);         }     } }