void Update() { ChunkInfo info = null; lock (_needsMesh) { if (_needsMesh.Count == 0) { _isGenerating = false; return; } info = _needsMesh.Dequeue(); } GameObject obj = (GameObject)Instantiate(_prefab, info.getPos(), Quaternion.identity); //GameObject obj = (GameObject)PhotonNetwork.Instantiate("Chunk", info.getPos(), Quaternion.identity, 0); Chunk chunk = ((Chunk)obj.GetComponent <Chunk>()); chunk.setInfo(info); chunk.generateMesh(); Vector3 pos = info.getPos(); int x = Mathf.FloorToInt(pos.x / Constants.chunkWidth); int z = Mathf.FloorToInt(pos.z / Constants.chunkWidth); if (!_chunks.ContainsKey(x)) { _chunks.Add(x, new Dictionary <int, Chunk>()); } _chunks[x].Add(z, chunk); }