Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public async void ActivateRage()
- {
- _isRage = true;
- _bonusChanger.SetBonus(data.GetRageBonus(),bonusInstantiated);
- await Task.Delay(5*1000);
- _bonusChanger.SetBonus(null,bonusInstantiated);
- _isRage = false;
- }
- //If return type Task you can await this method in place where you call it
- public async Task ActivateRageTask()
- {
- _isRage = true;
- _bonusChanger.SetBonus(data.GetRageBonus(),bonusInstantiated);
- await Task.Delay(5*1000);
- _bonusChanger.SetBonus(null,bonusInstantiated);
- _isRage = false;
- }
- private async void ExampleMethod()
- {
- ActivateRage();
- Debug.Log("done 1"); //this line will be called without delay
- await ActivateRageTask();
- Debug.Log("done 2"); //this line will be called only after ActivateRageTask finished (after delay 5s).
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement