Demigiant / dotween

A Unity C# animation engine. HOTween v2
http://dotween.demigiant.com
Other
2.29k stars 344 forks source link

WaitForCompletion stuck on recycled tween #675

Open Andarium opened 4 months ago

Andarium commented 4 months ago

Description: Creating new tweens while yielding WaitForCompletion can cause some WaitForCompletion to never end. Reproduced only when tween recycling is on (global or per-tween). Tweens associated with stuck WaitForCompletion are the same (by hash code) that were recycled and reused by other animation script instance.

Steps to reproduce:

  1. Create scene with some 3d objects (11 cubes in my case)
  2. Add same animation script below to these 3d objects
  3. Start Play Mode

Expected: All 3d object moving synchronously

Actual: Some 3d objects not moving, stuck on WaitForCompletion.

Reproduced: Unity 2023.2.10f1 with DOTween 1.2.745 and 1.2.765 Unity 2022.3.17f1 with DOTween 1.2.745

Settings: Recycable: true Safe Mode: false AutoPlay: false AutoKill: true

Sample code:


using System.Collections;
using DG.Tweening;
using UnityEngine;

public sealed class Animation : MonoBehaviour
{
    private IEnumerator Start()
    {
        yield return transform.DOLocalMoveY(0, 0.5f)
            .SetRecyclable(true)
            .Play()
            .WaitForCompletion();

        transform.DOLocalMoveY(1, 1)
            .SetLoops(-1, LoopType.Yoyo)
            .SetRecyclable(true)
            .Play();
    }
}