Open CraftedPvP opened 4 years ago
Having the same issue, didn't notice it for a bit and now it's cause bugs on my game.
My main issue is that it's a silent issue and it's hard to notice.
I would expect that calling setOnComplete more than once would do either of these :
Wrote a quick workaround, in case anyone needs this:
public class LeanTweenWrapper
{
public LTDescr Animation { get; }
public List<Action> OnCompleteCallBacks { get; }
public bool Executed { get; private set; }
public LeanTweenWrapper(LTDescr anim)
{
Animation = anim;
anim.setOnComplete(OnComplete);
OnCompleteCallBacks = new List<Action>();
Executed = false;
}
private void OnComplete()
{
if (Executed)
{
Debug.LogError("Tried to OnComplete more than once.");
return;
}
OnCompleteCallBacks.ForEach(c => c.Invoke());
Executed = true;
}
public void SetOnComplete(Action callback)
{
if (Executed)
{
Debug.LogError("Tried to assign callback to already completed anim.");
return;
}
OnCompleteCallBacks.Add(callback);
}
}
Hi, I've been having problems recently but I manage to fix it. There wasn't any forum that had this problem so I figured I shared this. I'm setting the OnComplete function twice in the end. Thinking it would concatenate the OnComplete Action parameter.
Apparently, it didn't work. I had to separate the OnComplete for it to work.
It would be nice if there was a warning that I'm setting it twice or some document saying you'll overwrite it.