I have a move sequence and when I DoPunScale does not trigger my callback function but when I insert it into the sequence in some other way it does get called. Here is the code:
private Sequence _moveSequenceBase = null;
private IEnumerator ScaleUpDownValue(float duration, int newValue, Action callback)
{
if (duration == 0)
{
SetInfoValue(newValue);
if (callback != null)
{
callback();
}
yield break;
}
if (_moveSequenceBase == null || !_moveSequenceBase.IsPlaying())
{
// Create a new sequence:
_moveSequenceBase = DOTween.Sequence();
var rectTransform = CurrentValueTextObj.GetComponent<RectTransform>();
_moveSequenceBase.InsertCallback(duration/2f, () => SetInfoValue(newValue));
/* THIS WORKS
if (callback != null)
{
_moveSequenceBase.InsertCallback(duration, () => callback());
}
*/
_moveSequenceBase.Append(rectTransform.DOPunchScale(new Vector3(1f, 1f, 1f), duration).OnComplete(() => {
// THIS DOES NOT WORK
if (callback != null)
{
callback();
}
}));
yield return _moveSequenceBase.WaitForCompletion();
}
else
{
// Wait for the sequence to finish
yield return null;
// then call ourselves to try again.
yield return ScaleUpDownValue(duration, newValue, callback);
}
}
Sorry for the complicated code but I don't have time to reduce the example further right now and hopefully it's not too hard to understand.
I have a move sequence and when I DoPunScale does not trigger my callback function but when I insert it into the sequence in some other way it does get called. Here is the code:
Sorry for the complicated code but I don't have time to reduce the example further right now and hopefully it's not too hard to understand.