VirtualFramework/Assets/Scripts/Item/HighLightFlashItem.cs
2025-02-07 11:15:59 +08:00

42 lines
1011 B
C#

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)
{
high = GetComponent<HighlightEffect>();
high.outline = 0.01f;
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;
}
}