0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Yarn Spinner 2.x のカスタムコマンドをasync/awaitで記述する方法

Posted at

Yarn Spinner 2.xのカスタムコマンドでは戻り値にIEnumeratorが使用可能です。
https://docs.yarnspinner.dev/using-yarnspinner-with-unity/creating-commands-functions#making-commands-using-coroutines

そこで、UniTaskのToCoroutine()を用いることでasync/awaitの書式でコマンドを実装できます。

	public class MyCommands
	{
		[YarnCommand("MyCommand")]
		public static IEnumerator MyCommand()
		{
			yield return UniTask.Create(async () =>
			{
				// ここに処理を書く。awaitも使える。
				await UniTask.Delay(200);
			}).ToCoroutine();
		}
	}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?