private void SemiUpdate() { if (UpdateTurn) { GameObject LoadChunk = null; for (int i = 0; i < chunks.GetLength(0); i++) { for (int j = 0; j < chunks.GetLength(1); j++) { if (!chunks[i, j].GetComponent <GenerateWorld>().IsChunkShowen() && !chunks[i, j].GetComponent <GenerateWorld>().IsReady()) { //chunks[i, j].GetComponent<GenerateWorld>().CreateChunk(); //return; if (LoadChunk == null) { LoadChunk = chunks[i, j]; } else if (Vector2.Distance(new Vector2(gameObject.transform.position.x, gameObject.transform.position.z), new Vector2(LoadChunk.transform.position.x, LoadChunk.transform.position.z)) > Vector2.Distance(new Vector2(gameObject.transform.position.x, gameObject.transform.position.z), new Vector2(chunks[i, j].transform.position.x, chunks[i, j].transform.position.z))) { LoadChunk = chunks[i, j]; } } } } if (LoadChunk != null) { //StartCoroutine(LoadChunk.GetComponent<GenerateWorld>().CreateChunk()); //ThreadStart myThreadDelegate = new ThreadStart(LoadChunk.GetComponent<GenerateWorld>().CreateChunk); GenerateWorld DW = LoadChunk.GetComponent <GenerateWorld>(); int X = (int)(LoadChunk.transform.position.x); int Z = (int)(LoadChunk.transform.position.z); ThreadStart myThreadDelegate = delegate { DW.CreateChunk(X, Z); //DW.DrawChunk(); };//new ThreadStart(chunks[i, j].GetComponent<GenerateWorld>().CreateChunk((int)chunks[i,j].transform.position.x, (int)chunks[i, j].transform.position.y)); Thread myThread = new Thread(myThreadDelegate); myThread.Start(); //chunks[i, j].GetComponent<GenerateWorld>().DrawChunk(); } for (int i = 0; i < chunks.GetLength(0); i++) { for (int j = 0; j < chunks.GetLength(1); j++) { if (!chunks[i, j].GetComponent <GenerateWorld>().IsChunkShowen() && chunks[i, j].GetComponent <GenerateWorld>().IsReady()) { chunks[i, j].GetComponent <GenerateWorld>().DrawChunk(); break; } } } } else { if (!DeleteQueue.IsEmpty()) { DeleteQueue.Remove().GetComponent <GenerateWorld>().DestroyChunk(); } } UpdateTurn = !UpdateTurn; }