2024-12-16 17:46:38 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
using DG.Tweening;
|
|
|
|
|
|
|
|
|
|
public class ScreenFlashEffect : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public Image screenEdgeImage; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>˸<EFBFBD><CBB8>UIԪ<49>أ<EFBFBD><D8A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD>ı<EFBFBD>ԵЧ<D4B5><D0A7><EFBFBD><EFBFBD>
|
|
|
|
|
public float flashDuration = 1f; // ÿ<><C3BF><EFBFBD><EFBFBD>˸<EFBFBD>ij<EFBFBD><C4B3><EFBFBD>ʱ<EFBFBD><CAB1>
|
|
|
|
|
public Color flashColor = new Color(1f, 0f, 0f, 0.5f); // <20><>ɫ<C9AB><CDB8><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD><EFBFBD><EFBFBD>ɫ
|
|
|
|
|
public float flashInterval = 1f; // <20><>˸<EFBFBD><CBB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF>0.5<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˸һ<EFBFBD>Σ<EFBFBD>
|
|
|
|
|
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
|
2024-12-25 15:39:40 +08:00
|
|
|
|
|
2024-12-16 17:46:38 +08:00
|
|
|
|
}
|
|
|
|
|
private void Start()
|
|
|
|
|
{
|
|
|
|
|
// <20><>ʼ<EFBFBD><CABC><EFBFBD><CDB8>״̬
|
|
|
|
|
screenEdgeImage.color = new Color(0, 0, 0, 0); // <20><>ʼ<CABC><CDB8>
|
2024-12-25 15:39:40 +08:00
|
|
|
|
|
2024-12-16 17:46:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void StartFlashing()
|
|
|
|
|
{
|
|
|
|
|
// ʹ<><CAB9>DOTween<65><6E>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD>˸<EFBFBD><CBB8><EFBFBD><EFBFBD>
|
|
|
|
|
Sequence sequence = DOTween.Sequence();
|
|
|
|
|
|
|
|
|
|
// 1. <20><><EFBFBD>䵽<EFBFBD><E4B5BD>ɫ
|
|
|
|
|
sequence.Append(screenEdgeImage.DOColor(flashColor, flashDuration).SetEase(Ease.InOutQuad));
|
|
|
|
|
|
|
|
|
|
// 2. <20>ٽ<EFBFBD><D9BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><CDB8>
|
|
|
|
|
sequence.Append(screenEdgeImage.DOColor(new Color(0, 0, 0, 0), flashDuration).SetEase(Ease.InOutQuad));
|
|
|
|
|
|
|
|
|
|
// 3. ѭ<><D1AD><EFBFBD><EFBFBD>˸
|
2024-12-25 15:39:40 +08:00
|
|
|
|
//sequence.SetLoops(-1, LoopType.Yoyo); // <20><><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Yoyo<79><6F>
|
|
|
|
|
|
2024-12-16 17:46:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void StopFlashing()
|
|
|
|
|
{
|
|
|
|
|
// ȡ<><C8A1><EFBFBD><EFBFBD>˸Ч<CBB8><D0A7>
|
|
|
|
|
screenEdgeImage.color = new Color(0, 0, 0, 0); // <20>ָ<EFBFBD><EFBFBD><CDB8>
|
|
|
|
|
DOTween.Kill(screenEdgeImage); // ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>DOTween<65><6E><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
}
|