Skip to content

Commit bf55f5c

Browse files
committed
fixed a bug, nesting transitions may not be played.
1 parent 21a238e commit bf55f5c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Assets/Scripts/UI/Transition.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public class Transition : ITweenListener
5050
float _startTime;
5151
float _endTime;
5252
GTweenCallback _delayedCallDelegate;
53+
GTweenCallback _checkAllDelegate;
5354
GTweenCallback1 _delayedCallDelegate2;
5455

5556
const int OPTION_IGNORE_DISPLAY_CONTROLLER = 1;
@@ -64,6 +65,7 @@ public Transition(GComponent owner)
6465

6566
_delayedCallDelegate = OnDelayedPlay;
6667
_delayedCallDelegate2 = OnDelayedPlayItem;
68+
_checkAllDelegate = CheckAllComplete;
6769
}
6870

6971
/// <summary>
@@ -779,7 +781,7 @@ void InternalPlay()
779781
_ownerBaseX = _owner.x;
780782
_ownerBaseY = _owner.y;
781783

782-
_totalTasks = 0;
784+
_totalTasks = 1; //prevent to complete inside the loop
783785

784786
bool needSkipAnimations = false;
785787
int cnt = _items.Length;
@@ -814,6 +816,8 @@ void InternalPlay()
814816

815817
if (needSkipAnimations)
816818
SkipAnimations();
819+
820+
_totalTasks--;
817821
}
818822

819823
void PlayItem(TransitionItem item)
@@ -1175,12 +1179,18 @@ void CheckAllComplete()
11751179
if (_totalTimes < 0)
11761180
{
11771181
InternalPlay();
1182+
if (_totalTasks == 0)
1183+
GTween.DelayedCall(0).SetTarget(this).OnComplete(_checkAllDelegate);
11781184
}
11791185
else
11801186
{
11811187
_totalTimes--;
11821188
if (_totalTimes > 0)
1189+
{
11831190
InternalPlay();
1191+
if (_totalTasks == 0)
1192+
GTween.DelayedCall(0).SetTarget(this).OnComplete(_checkAllDelegate);
1193+
}
11841194
else
11851195
{
11861196
_playing = false;

0 commit comments

Comments
 (0)