Unityのサブスレッドで5msごとに処理
多分こんな感じ
以下を参考にしました。
https://teratail.com/questions/109591
using UnityEngine;
using System.Threading;
using System;
public class UnitySubThreadTimer : MonoBehaviour
{
Thread thread;
// Start is called before the first frame update
void Start()
{
thread = new Thread(new ThreadStart(SubThread));
thread.Start();
}
void SubThread()
{
//Process once every 5ms
long next = DateTime.Now.Ticks + 50000;
long now;
while (true)
{
try
{
Debug.Log(Time.time);
}
catch
{
}
do
{
now = DateTime.Now.Ticks;
}
while (now < next);
next += 50000;
}
}
void Stop()
{
thread.Abort();
}
void OnApplicationQuit()
{
thread.Abort();
}
}