Documentation for the Unity C# Library
Loading...
Searching...
No Matches
Delay.cs
Go to the documentation of this file.
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Threading.Tasks;
5using UnityEngine;
6
7namespace PixoVR.Event
8{
12 public class Delay : IStep
13 {
14 public event Action OnFunctionFinished;
15
16 public void StartStep(StepItem stepItem, StepFunction function, List<InteractableClass> interactables = null,
17 Action onStepSkipped = null)
18 {
19 if (int.TryParse(function.value, out int value))
20 {
21 DelayInvoke(value);
22 }
23 else
24 {
25 Debug.Log("Parse error. Use int number format");
26 }
27 }
28
29 private async void DelayInvoke(int delayInSeconds)
30 {
31 await Task.Delay(delayInSeconds * 1000);
33 }
34
35 public void FunctionFinished()
36 {
37 OnFunctionFinished?.Invoke();
38 }
39 }
40}
Next function execution delay in seconds function.
Definition Delay.cs:13
void StartStep(StepItem stepItem, StepFunction function, List< InteractableClass > interactables=null, Action onStepSkipped=null)
Definition Delay.cs:16
async void DelayInvoke(int delayInSeconds)
Definition Delay.cs:29
Action OnFunctionFinished
Definition Delay.cs:14
void FunctionFinished()
Called to end current step and start a next one.
Definition Delay.cs:35
[Serializable]
Definition StepItem.cs:12
Basic interface of functions. (Please note that iStep is a wrong name)
Definition IStep.cs:10