Bugfix/master
This commit is contained in:
@@ -9,7 +9,7 @@ public class ScreenEffectManager : MonoBehaviour
|
||||
|
||||
public Volume saturation;
|
||||
|
||||
private ColorAdjustments colorAdjustments;
|
||||
// private ColorAdjustments colorAdjustments;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -28,26 +28,31 @@ public class ScreenEffectManager : MonoBehaviour
|
||||
private void Start()
|
||||
{
|
||||
// 获取 ColorAdjustments 设置
|
||||
if (saturation.profile.TryGet(out colorAdjustments))
|
||||
{
|
||||
Debug.Log("ColorAdjustments is available.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("ColorAdjustments settings not found in PostProcessProfile.");
|
||||
}
|
||||
// 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)
|
||||
if (saturation != null)
|
||||
{
|
||||
// 使用 DOTween 创建一个饱和度过渡动画
|
||||
// 将targetSaturation (0~1) 转换为weight (1~0)
|
||||
// targetSaturation = 0 时,weight = 1 (完全褪色)
|
||||
// targetSaturation = 1 时,weight = 0 (正常颜色)
|
||||
float targetWeight = 1f - targetSaturation;
|
||||
|
||||
// 使用 DOTween 创建一个weight过渡动画
|
||||
Tween tween = DOTween.To(
|
||||
() => colorAdjustments.saturation.value, // 获取当前饱和度值
|
||||
x => colorAdjustments.saturation.value = x, // 设置新的饱和度值
|
||||
targetSaturation, // 目标饱和度值
|
||||
() => saturation.weight, // 获取当前weight值
|
||||
x => saturation.weight = x, // 设置新的weight值
|
||||
targetWeight, // 目标weight值
|
||||
duration // 过渡持续时间
|
||||
);
|
||||
|
||||
@@ -55,8 +60,18 @@ public class ScreenEffectManager : MonoBehaviour
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("ColorAdjustments settings not found.");
|
||||
Debug.LogError("Saturation Volume not found.");
|
||||
return null; // 如果找不到设置,返回 null
|
||||
}
|
||||
}
|
||||
|
||||
// 重置饱和度效果
|
||||
public void ResetSaturation()
|
||||
{
|
||||
if (saturation != null)
|
||||
{
|
||||
// 直接设置weight为0,恢复正常颜色
|
||||
saturation.weight = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user