Exemplo n.º 1
0
        /// <summary>
        /// Force an update of all tilechunks. This is called after changing sensitive data like CellSize, Collider depth, etc
        /// </summary>
        /// <param name="refreshMesh"></param>
        /// <param name="refreshMeshCollider"></param>
        public void Refresh(bool refreshMesh = true, bool refreshMeshCollider = true, bool refreshTileObjects = false, bool invalidateBrushes = false)
        {
            BuildTilechunkDictionary();
            var valueIter = m_dicChunkCache.Values.GetEnumerator();

            while (valueIter.MoveNext())
            {
                TilemapChunk chunk = valueIter.Current;
                if (chunk)
                {
                    if (refreshMesh)
                    {
                        chunk.InvalidateMesh();
                    }
                    if (refreshMeshCollider)
                    {
                        chunk.InvalidateMeshCollider();
                    }
                    if (refreshTileObjects)
                    {
                        chunk.RefreshTileObjects();
                    }
                    if (invalidateBrushes)
                    {
                        chunk.InvalidateBrushes();
                    }
                }
            }
            UpdateMesh();
        }
Exemplo n.º 2
0
 /// <summary>
 /// Force an update of all tilechunks. This is called after changing sensitive data like CellSize, Collider depth, etc
 /// </summary>
 /// <param name="refreshMesh"></param>
 /// <param name="refreshMeshCollider"></param>
 public void Refresh(bool refreshMesh = true, bool refreshMeshCollider = true, bool refreshTileObjects = false, bool invalidateBrushes = false)
 {
     for (int i = 0; i < transform.childCount; ++i)
     {
         TilemapChunk chunk = transform.GetChild(i).GetComponent <TilemapChunk>();
         if (chunk != null)
         {
             if (refreshMesh)
             {
                 chunk.InvalidateMesh();
             }
             if (refreshMeshCollider)
             {
                 chunk.InvalidateMeshCollider();
             }
             if (refreshTileObjects)
             {
                 chunk.RefreshTileObjects();
             }
             if (invalidateBrushes)
             {
                 chunk.InvalidateBrushes();
             }
         }
     }
     UpdateMesh();
 }
Exemplo n.º 3
0
        public bool InvalidateChunkAt(int gridX, int gridY, bool invalidateMesh = true, bool invalidateMeshCollider = true)
        {
            TilemapChunk chunk = GetOrCreateTileChunk(gridX, gridY);

            if (chunk != null)
            {
                chunk.InvalidateMesh();
                chunk.InvalidateMeshCollider();
                return(true);
            }
            return(false);
        }