Ver.0.3.0.33
This commit is contained in:
@@ -1,26 +1,16 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using DG.Tweening;
|
||||
using Yarn.Unity;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
using System.Collections;
|
||||
|
||||
public class ScreenEffectManager : MonoBehaviour
|
||||
{
|
||||
public static ScreenEffectManager Instance { get; private set; }
|
||||
|
||||
public Image blackoutPanel; // 黑屏面板
|
||||
public Image redFlashPanel; // 红色闪烁面板
|
||||
private float shakeDuration = 0.5f; // 震屏持续时间
|
||||
private float shakeIntensity = 0.04f; // 震屏强度
|
||||
|
||||
public Volume saturation;
|
||||
|
||||
private ColorAdjustments colorAdjustments;
|
||||
|
||||
private Vector3 originalCameraPosition;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
// 确保单例模式
|
||||
@@ -37,8 +27,6 @@ public class ScreenEffectManager : MonoBehaviour
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// 保存初始相机位置
|
||||
originalCameraPosition = Camera.main.transform.localPosition;
|
||||
// 获取 ColorAdjustments 设置
|
||||
if (saturation.profile.TryGet(out colorAdjustments))
|
||||
{
|
||||
@@ -50,48 +38,6 @@ public class ScreenEffectManager : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
// 震屏效果
|
||||
[YarnCommand("shakeScreen")]
|
||||
public IEnumerator ShakeScreen()
|
||||
{
|
||||
yield return Camera.main.transform.DOPunchPosition(new Vector3(1, 0, 0) * shakeIntensity, shakeDuration, 8, 1f)
|
||||
.WaitForCompletion();
|
||||
}
|
||||
|
||||
// 黑屏淡入淡出效果
|
||||
[YarnCommand("fadeIn")]
|
||||
public IEnumerator FadeIn(float duration)
|
||||
{
|
||||
blackoutPanel.gameObject.SetActive(true);
|
||||
Sequence fadeInSequence = DOTween.Sequence();
|
||||
fadeInSequence.Append(blackoutPanel.DOFade(1f, duration));
|
||||
//fadeInSequence.AppendInterval(waitTime);
|
||||
yield return fadeInSequence.WaitForCompletion();
|
||||
}
|
||||
|
||||
[YarnCommand("fadeOut")]
|
||||
public IEnumerator FadeOut(float duration)
|
||||
{
|
||||
Sequence fadeOutSequence = DOTween.Sequence();
|
||||
fadeOutSequence.Append(blackoutPanel.DOFade(0f, duration).OnComplete(() =>
|
||||
{
|
||||
blackoutPanel.gameObject.SetActive(false);
|
||||
}));
|
||||
yield return fadeOutSequence.WaitForCompletion();
|
||||
}
|
||||
|
||||
// 红色闪烁效果
|
||||
[YarnCommand("flashRed")]
|
||||
public IEnumerator FlashRed(float duration)
|
||||
{
|
||||
redFlashPanel.gameObject.SetActive(true);
|
||||
yield return redFlashPanel.DOFade(1, duration / 2).WaitForCompletion();
|
||||
yield return redFlashPanel.DOFade(0, duration / 2).OnComplete(() =>
|
||||
{
|
||||
redFlashPanel.gameObject.SetActive(false);
|
||||
}).WaitForCompletion();
|
||||
}
|
||||
|
||||
// 动态调整饱和度
|
||||
public Tween TweenSaturation(float targetSaturation, float duration)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user