Beispiel #1
0
    private IEnumerator SetupChunks()
    {
        int i = 0;

        worldLoadingStatus.isLoading     = true;
        worldLoadingStatus.loadingText   = "Loading Chunk";
        worldLoadingStatus.finishAmount  = chunksY * chunksX;
        worldLoadingStatus.currentAmount = 0;
        if (preloadedChunks != null && preloadedChunks.Length > 0)
        {
            for (int p = 0; p < preloadedChunks.Length; p++)
            {
                InitChunk(preloadedChunks[p]);
            }
        }
        else
        {
            for (int y = 0; y < chunksY; y++)
            {
                for (int x = 0; x < chunksX; x++)
                {
                    InitChunk(InstantiateChunk(x, y));
                    i++;
                    if (i % 250 == 0)
                    {
                        yield return(null);
                    }

                    worldLoadingStatus.Increment();
                }
            }
        }
    }