using Ichni.RhythmGame.Beatmap; using UnityEngine; using UnityEngine.Rendering.Universal; namespace Ichni.RhythmGame { public class VignetteEffect : EffectBase { #region [效果参数] Effect Parameters public float peak; public float smoothness; public Color color; public AnimationCurve intensityCurve; private Vignette _vignette; #endregion #region [初始化] Initialization public VignetteEffect(float effectTime, float peak, float smoothness, Color color, AnimationCurve intensityCurve) : base(effectTime) { this.effectTime = effectTime; this.peak = peak; this.smoothness = smoothness; this.color = color; this.intensityCurve = intensityCurve; } private void PrepareEffectHandle() { if (_vignette == null && PostProcessingManager.GlobalVolume != null) { PostProcessingManager.GlobalVolume.profile.TryGet(out _vignette); } } #endregion #region [效果逻辑覆盖] Effect Pattern Overrides public override void PreExecute() { PrepareEffectHandle(); if (_vignette != null) { _vignette.smoothness.value = smoothness; _vignette.color.value = color; } } public override void Execute() { if (_vignette != null) { float currentIntensity = intensityCurve.Evaluate(effectProgressPercent) * peak; _vignette.intensity.value = currentIntensity; } } // 注意暗角和其它的不同,它的默认值通常不是0而是类似0.2左右 public override void Adjust() { ResetEffect(); } public override void Recover() { ResetEffect(); } public override void Disrupt() { ResetEffect(); } private void ResetEffect() { if (_vignette != null) _vignette.intensity.value = 0f; // 你可以修改为符合你游戏默认画风的默认暗角值 } #endregion } }