コード例 #1
0
    IEnumerator BakeWorld(NavCube navCube, Vector3Int origin, Vector3Int numberChunk, string folderPath)
    {
        NavCubeChunk currentChunk;
        Vector3Int   currentChunkPos = new Vector3Int();

        NavCubeWorld ncw = NavCubeWorld.LoadOrCreate(folderPath);         //LoadOrCreateWorld(folderPath);

        navCube.world = ncw;

        //ncw.chunks.Clear();

        for (int x = 0; x < numberChunk.x; x++)
        {
            currentChunkPos.x = x + origin.x;
            for (int y = 0; y < numberChunk.y; y++)
            {
                currentChunkPos.y = y + origin.y;
                for (int z = 0; z < numberChunk.z; z++)
                {
                    currentChunkPos.z = z + origin.z;
                    currentChunk      = ncw.LoadOrCreateChunk(currentChunkPos);

                    yield return(navCube.BakeChunk(currentChunk));

                    ncw.SaveChunk(currentChunk);

                    //EditorUtility.SetDirty(currentChunk);
                }
            }
        }


        //AssetDatabase.SaveAssets();
        //AssetDatabase.Refresh();


        yield return(null);

        IsBaking = false;
        //navCube.MakeNavCubeRender();

        SceneView.RepaintAll();
    }
コード例 #2
0
    IEnumerator BakeChunk(NavCube navCube, Vector3Int chunk)
    {
        if (navCube.world != null)
        {
            NavCubeChunk ncc = navCube.world.LoadOrCreateChunk(chunk);
            if (ncc != null)
            {
                yield return(navCube.BakeChunk(ncc));

                navCube.world.SaveChunk(ncc);
            }
        }
        yield return(null);

        IsBaking = false;
        //navCube.MakeNavCubeRender();

        SceneView.RepaintAll();
    }