game(scripts): standardise VignetteBreathing
This commit is contained in:
parent
5417c57b66
commit
288e3647d5
1 changed files with 18 additions and 19 deletions
|
@ -1,34 +1,33 @@
|
||||||
using System.Collections;
|
/*
|
||||||
using System.Collections.Generic;
|
* Author: Reza
|
||||||
|
* Date: 7/2/25
|
||||||
|
* Description: Vignette breathing effect
|
||||||
|
*/
|
||||||
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Rendering;
|
using UnityEngine.Rendering;
|
||||||
using UnityEngine.Rendering.Universal;
|
using UnityEngine.Rendering.Universal;
|
||||||
|
|
||||||
public class VignetteBreathing : MonoBehaviour
|
public class VignetteBreathing : MonoBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField]
|
[SerializeField] public Volume postProcessingVolume;
|
||||||
public Volume postProcessingVolume;
|
|
||||||
|
[SerializeField] public AnimationCurve intensityCurve; // Assign in Inspector
|
||||||
private Vignette vignette;
|
|
||||||
|
|
||||||
[SerializeField]
|
|
||||||
public AnimationCurve intensityCurve; // Assign in Inspector
|
|
||||||
public float cycleDuration = 3f; // Time for one full cycle
|
public float cycleDuration = 3f; // Time for one full cycle
|
||||||
|
|
||||||
void Start()
|
private Vignette _vignette;
|
||||||
|
|
||||||
|
private void Start()
|
||||||
{
|
{
|
||||||
if (postProcessingVolume.profile.TryGet(out vignette))
|
if (postProcessingVolume.profile.TryGet(out _vignette)) Debug.Log("Vignette found!");
|
||||||
{
|
|
||||||
Debug.Log("Vignette found!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
if (vignette != null)
|
if (!_vignette) return;
|
||||||
{
|
|
||||||
float t = (Time.time % cycleDuration) / cycleDuration; // Loop 0-1 over time
|
var t = Time.time % cycleDuration / cycleDuration; // Loop 0-1 over time
|
||||||
vignette.intensity.Override(intensityCurve.Evaluate(t));
|
_vignette.intensity.Override(intensityCurve.Evaluate(t));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue