Created
May 22, 2019 18:02
-
-
Save nekomimi-daimao/5db8713d45ddbf166d4ddcf0add46400 to your computer and use it in GitHub Desktop.
check => heavy method stops ui
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
using System.Threading.Tasks; | |
using UnityEngine; | |
using UnityEngine.UI; | |
public class WhoStopsUI : MonoBehaviour | |
{ | |
private void Suspect() | |
{ | |
// something heavy... | |
} | |
#region Detective office | |
void Start() | |
{ | |
Investigator(); | |
} | |
[SerializeField] private Text _investigatorText; | |
private async Task Investigator() | |
{ | |
while (this.enabled) | |
{ | |
_investigatorText.text = "3"; | |
await Task.Delay(1000); | |
_investigatorText.text = "2"; | |
await Task.Delay(1000); | |
_investigatorText.text = "1"; | |
await Task.Delay(1000); | |
_investigatorText.text = "in"; | |
await Task.Run(() => Suspect()); | |
_investigatorText.text = "out"; | |
await Task.Delay(3000); | |
} | |
} | |
[SerializeField] private Text _counterText; | |
private long _counter = 0; | |
void FixedUpdate() | |
{ | |
_counter++; | |
_counterText.text = _counter.ToString(); | |
} | |
#endregion | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment