Exemple #1
0
    private void CreateChunkInstance()
    {
        _Chunk = GameObject.Instantiate(ChunkBuilder.GetChunkLOD(this._Lod));
        _Chunk.SetActive(true);
        _Chunk.transform.parent = this._Parent;
        _Chunk.isStatic         = true;

        _Chunk.transform.localPosition = _LocalPosition;
        _Chunk.transform.localRotation = Quaternion.identity;

        MeshFilter filter  = _Chunk.GetComponent <MeshFilter>();
        Mesh       newMesh = UpdateMesh(filter.mesh);

        filter.mesh = newMesh;

        if (_Lod <= 3)
        {
            MeshCollider col = _Chunk.GetComponent <MeshCollider>();
            col.enabled    = true;
            col.sharedMesh = newMesh;
        }
    }