VirtualFramework/Assets/Scripts/Item/HighLightFlashItem.cs

42 lines
1011 B
C#
Raw Normal View History

2025-02-06 16:26:44 +08:00
using DG.Tweening;
using DG.Tweening.Core;
using DG.Tweening.Plugins.Options;
using HighlightPlus;
using QFramework;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HighLightFlashItem : MonoBehaviour
{
HighlightEffect high;
TweenerCore<float, float, FloatOptions> dotw;
public void Init(float time, int count = -1, string finishedEvent = null)
{
2025-02-06 16:45:09 +08:00
high = GetComponent<HighlightEffect>();
2025-02-07 11:15:59 +08:00
high.outline = 0.01f;
2025-02-06 16:26:44 +08:00
dotw = DOTween.To(() => high.outline, (v) => high.outline = v, 1, time).SetEase(Ease.OutFlash).SetLoops(count, LoopType.Yoyo).OnComplete(() =>
{
if (string.IsNullOrEmpty(finishedEvent)==false)
{
StringEventSystem.Global.Send(finishedEvent);
}
this.Stop();
});
}
public void Stop()
{
if (dotw != null)
{
dotw.Kill();
dotw = null;
}
high.highlighted = false;
}
}