Unity 非同期処理(スレッド)
■Unityの非同期処理(スレッド)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading;
using System.Threading.Tasks;
public class TestA : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
// Task型の戻り値を変数「‗」に入れる
var _ = test();
}
// Update is called once per frame
void Update()
{
}
private async Task test() {
Debug.Log("start");
await Task.Run(() => {
Thread.Sleep(3000);
});
Debug.Log("end");
}
}