From a7a6af0a68d6482dc6728a9be4805b7f5cb85900 Mon Sep 17 00:00:00 2001 From: hadashiA Date: Fri, 8 Sep 2023 09:36:42 +0900 Subject: [PATCH] Fix AwakeMonitor to not duplicates --- .../UniTask/Runtime/Triggers/AsyncDestroyTrigger.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/Triggers/AsyncDestroyTrigger.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/Triggers/AsyncDestroyTrigger.cs index 48fbdcc..77c9285 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/Triggers/AsyncDestroyTrigger.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/Triggers/AsyncDestroyTrigger.cs @@ -32,13 +32,11 @@ namespace Cysharp.Threading.Tasks.Triggers if (cancellationTokenSource == null) { cancellationTokenSource = new CancellationTokenSource(); + if (!awakeCalled) + { + PlayerLoopHelper.AddAction(PlayerLoopTiming.Update, new AwakeMonitor(this)); + } } - - if (!awakeCalled) - { - PlayerLoopHelper.AddAction(PlayerLoopTiming.Update, new AwakeMonitor(this)); - } - return cancellationTokenSource.Token; } }