多线程的使用
线程里面不能含有Unity组件等,只能 用于一些 纯C#代码( 数值、类的计算,初始化)
...
using System.Threading;
...
void Start()
{
...
ThreadStart ref = new ThreadStart(testThread);
Thread thread = new Thread(ref);
thread.Start();
...
}
...
private void testThread()
{
int num1 = 1000, num2 = 100;
for (int i = 0; i < num1; i++)
{
...
for (int j = 0; j < num2; j++)
{
...
}//
...
}//
}//
...
测试打包后能否正常使用
using UnityEngine;
using System.Threading;
using UnityEngine.UI;
public class TestThread : MonoBehaviour
{
public string str = "";
public Text text;
bool threadDone = false;
// Start is called before the first frame update
void Star