Files
aibis-dream/Assets/Scripts/FixSystem/Effect/ScreenEffectManager.cs
T
dingyuntian 9f20ef52d8 UI工具翻新
1. 增加UI工具
2. 增加设置页面
3. GameLoop更新
4. 导入ActionKit工具
2025-04-21 18:53:30 +08:00

62 lines
1.7 KiB
C#

using UnityEngine;
using DG.Tweening;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
public class ScreenEffectManager : MonoBehaviour
{
public static ScreenEffectManager Instance { get; private set; }
public Volume saturation;
private ColorAdjustments colorAdjustments;
private void Awake()
{
// 确保单例模式
if (Instance != null && Instance != this)
{
Destroy(gameObject);
}
else
{
Instance = this;
DontDestroyOnLoad(gameObject); // 可选:保持在场景加载之间
}
}
private void Start()
{
// 获取 ColorAdjustments 设置
if (saturation.profile.TryGet(out colorAdjustments))
{
Debug.Log("ColorAdjustments is available.");
}
else
{
Debug.LogError("ColorAdjustments settings not found in PostProcessProfile.");
}
}
// 动态调整饱和度
public Tween TweenSaturation(float targetSaturation, float duration)
{
if (colorAdjustments != null)
{
// 使用 DOTween 创建一个饱和度过渡动画
Tween tween = DOTween.To(
() => colorAdjustments.saturation.value, // 获取当前饱和度值
x => colorAdjustments.saturation.value = x, // 设置新的饱和度值
targetSaturation, // 目标饱和度值
duration // 过渡持续时间
);
return tween; // 返回 Tween 对象
}
else
{
Debug.LogError("ColorAdjustments settings not found.");
return null; // 如果找不到设置,返回 null
}
}
}