protected void Process(System.Action <int, int> act, System.Action end) { counter = 0; for (int i = 0; i < threadUnit; i++) { for (int j = 0; j < threadUnit; j++) { tData u = new tData(); u.x1 = rect.xMin + xUnit * i; u.x2 = u.x1 + xUnit; u.y1 = rect.yMin + yUnit * j; u.y2 = u.y1 + yUnit; u.act = act; Thread thread = new Thread(ThreadMission); thread.Start(u); } } EditorCoroutineRunner.StartEditorCoroutine(End(end)); }
private void ThreadMission(object obj) { try { tData u = (tData)obj; for (int i = u.x1; i < u.x2; i++) { for (int j = u.y1; j < u.y2; j++) { if (u.act != null) { u.act(i, j); } } } counter++; //Debug.Log (string.Format ("x1:{0} x2:{1} y1:{2} y2:{3} counter:{4}",u.x1, u.x2, u.y1, u.y2, counter)); } catch (System.Exception e) { Debug.LogError("Thread exception:" + e.ToString()); } }