Files
ichni_Official/Assets/Scripts/Game/GameElements/GeneralEffects/VignetteEffect.cs

73 lines
2.2 KiB
C#
Raw Normal View History

2025-06-03 02:42:28 -04:00
using Ichni.RhythmGame.Beatmap;
using UnityEngine;
using UnityEngine.Rendering.Universal;
namespace Ichni.RhythmGame
{
public class VignetteEffect : EffectBase
{
2026-03-14 03:13:10 -04:00
#region [] Effect Parameters
2025-06-03 02:42:28 -04:00
public float duration;
public float peak;
public float smoothness;
public Color color;
public AnimationCurve intensityCurve;
2026-03-14 03:13:10 -04:00
private Vignette _vignette;
#endregion
2025-06-03 02:42:28 -04:00
2026-03-14 03:13:10 -04:00
#region [] Initialization
2025-06-03 02:42:28 -04:00
public VignetteEffect(float duration, float peak, float smoothness, Color color, AnimationCurve intensityCurve)
2026-03-14 03:13:10 -04:00
: base(duration)
2025-06-03 02:42:28 -04:00
{
this.duration = duration;
this.peak = peak;
this.smoothness = smoothness;
this.color = color;
this.intensityCurve = intensityCurve;
}
2026-03-14 03:13:10 -04:00
private void PrepareEffectHandle()
2025-06-03 02:42:28 -04:00
{
2026-03-14 03:13:10 -04:00
if (_vignette == null && PostProcessingManager.GlobalVolume != null)
2025-06-03 02:42:28 -04:00
{
2026-03-14 03:13:10 -04:00
PostProcessingManager.GlobalVolume.profile.TryGet(out _vignette);
2025-06-03 02:42:28 -04:00
}
}
2026-03-14 03:13:10 -04:00
#endregion
2025-06-03 02:42:28 -04:00
2026-03-14 03:13:10 -04:00
#region [] Effect Pattern Overrides
public override void PreExecute()
2025-06-03 02:42:28 -04:00
{
2026-03-14 03:13:10 -04:00
PrepareEffectHandle();
if (_vignette != null)
2025-06-03 02:42:28 -04:00
{
2026-03-14 03:13:10 -04:00
_vignette.smoothness.value = smoothness;
_vignette.color.value = color;
2025-06-03 02:42:28 -04:00
}
2026-03-14 03:13:10 -04:00
}
public override void Execute()
{
if (_vignette != null)
2025-06-03 02:42:28 -04:00
{
2026-03-14 03:13:10 -04:00
float currentIntensity = intensityCurve.Evaluate(effectProgressPercent) * peak;
_vignette.intensity.value = currentIntensity;
2025-06-03 02:42:28 -04:00
}
}
2026-03-14 03:13:10 -04:00
// 注意暗角和其它的不同它的默认值通常不是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
2025-06-03 02:42:28 -04:00
}
2026-03-14 03:13:10 -04:00
}