-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from nowsprinting/fix/duplicate_agents
Fix duplicate agent creation when reactivating scene
- Loading branch information
Showing
5 changed files
with
146 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) 2023-2024 DeNA Co., Ltd. | ||
// This software is released under the MIT License. | ||
|
||
using System.Threading; | ||
using Cysharp.Threading.Tasks; | ||
using DeNA.Anjin.Agents; | ||
using UnityEngine; | ||
|
||
namespace DeNA.Anjin.TestDoubles | ||
{ | ||
/// <summary> | ||
/// Spy agent that count the number of alive instances. | ||
/// </summary> | ||
[AddComponentMenu("")] | ||
// ReSharper disable once RequiredBaseTypesIsNotInherited | ||
public class SpyAliveCountAgent : AbstractAgent | ||
{ | ||
public static int AliveInstances { get; private set; } | ||
|
||
public override async UniTask Run(CancellationToken token) | ||
{ | ||
AliveInstances++; | ||
try | ||
{ | ||
await UniTask.WaitWhile(() => true, cancellationToken: token); // Wait indefinitely | ||
} | ||
finally | ||
{ | ||
AliveInstances--; | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.