多線程代碼:
using System.Collections;
using System.Threading;
using Unity.Collections;
using UnityEngine;
public class MyThread : MonoBehaviour
{
void Start()
{
// 多線程
// 指定線程要運行的程序(函數)
ThreadStart threadStart = new ThreadStart(MyThreadFun);
// 創建多線程對象
Thread thread = new Thread(threadStart);
// 運行多線程
thread.Start();
}
void MyThreadFun()
{
for (int i = 0; i < 100; i++)
{
Debug.Log("我是多線程:" + i);
}
}
}