Skip to content

Instantly share code, notes, and snippets.

@nekomimi-daimao
Created May 22, 2019 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nekomimi-daimao/5db8713d45ddbf166d4ddcf0add46400 to your computer and use it in GitHub Desktop.
Save nekomimi-daimao/5db8713d45ddbf166d4ddcf0add46400 to your computer and use it in GitHub Desktop.
check => heavy method stops ui
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