Created
July 3, 2017 15:21
-
-
Save onionmk2/2cb50329acdb47af52a92091712c68fe to your computer and use it in GitHub Desktop.
Async Action in Behaviour Designer
This file contains hidden or 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
| using System.Collections; | |
| using BehaviorDesigner.Runtime.Tasks; | |
| using UnityEngine; | |
| internal class AsyncAction : Action | |
| { | |
| private bool isCoroutineRunning; | |
| public override void OnStart() | |
| { | |
| StartCoroutine(DoAction()); | |
| } | |
| public override TaskStatus OnUpdate() | |
| { | |
| return isCoroutineRunning ? TaskStatus.Running : TaskStatus.Success; | |
| } | |
| private IEnumerator DoAction() | |
| { | |
| isCoroutineRunning = true; | |
| yield return null; | |
| isCoroutineRunning = false; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment