Чтобы лучше объяснить фактический визуальный - например - Лесная плитка, когда расположена в одиночестве, есть деревья, которые слегка проходят через верхнюю часть шестиугольника. Поместив плитки на вершине этого, эти деревья должны быть - в правилах плитки, видимыми поверх плитки поверх них, поэтому они смешиваются. Вместо этого деревья, которые проходят через фактическую плитку, вырезаны верхней плитки. Br />using UnityEngine;
using UnityEngine.Tilemaps;
using System.Collections.Generic;
[CreateAssetMenu(fileName = "New Custom Hexagonal Rule Tile", menuName = "Tiles/Custom Hexagonal Rule Tile")]
public class CustomHexagonalRuleTile : HexagonalRuleTile
{
public List possibleTiles; // List of possible tiles that share the same directional rules
// Define the positions of the neighbors in a pointy top hexagonal grid
private static readonly Vector3Int[] HexagonalNeighbors = new Vector3Int[]
{
new Vector3Int(1, 0, 0), // Right
new Vector3Int(1, -1, 0), // Bottom Right
new Vector3Int(0, -1, 0), // Bottom Left
new Vector3Int(-1, 0, 0), // Left
new Vector3Int(-1, 1, 0), // Top Left
new Vector3Int(0, 1, 0) // Top Right
};
public override void GetTileData(Vector3Int position, ITilemap tilemap, ref TileData tileData)
{
base.GetTileData(position, tilemap, ref tileData);
// Check for overflow from the Top Right
Vector3Int topRight = position + HexagonalNeighbors[5];
if (tilemap.GetTile(topRight) == this)
{
// Handle overflow from the Top Right
// Randomly select a tile from the list of possible tiles
if (possibleTiles != null && possibleTiles.Count > 0)
{
TileBase selectedTile = possibleTiles[Random.Range(0, possibleTiles.Count)];
tileData.sprite = ((Tile)selectedTile).sprite; // Set the sprite of the selected tile
tileData.transform = Matrix4x4.Translate(new Vector3(0, 0.5f, 0)); // Adjust the position to show overflow
}
}
// Check for overflow from the Top Left
Vector3Int topLeft = position + HexagonalNeighbors[4];
if (tilemap.GetTile(topLeft) == this)
{
// Handle overflow from the Top Left
// Randomly select a tile from the list of possible tiles
if (possibleTiles != null && possibleTiles.Count > 0)
{
TileBase selectedTile = possibleTiles[Random.Range(0, possibleTiles.Count)];
tileData.sprite = ((Tile)selectedTile).sprite; // Set the sprite of the selected tile
tileData.transform = Matrix4x4.Translate(new Vector3(0, 0.5f, 0)); // Adjust the position to show overflow
}
}
}
}
< /code>
Я думаю, что, может быть, проблема в том, что я не могу правильно указать, что такое «переполнение». Кто -нибудь когда -нибудь имел опыт работы с этим? = "https://postimg.cc/cvb68tgc" src = "https://i.sstatic.net/nua74s8p.png" /> < /p>
Как видите, на пустых плитках есть переполнение пустых плиток, но, когда я помещаю плитку, «переполнение» исчезает, что делает их менее плотно плотно вместе. Прошу прощения за то, что не добавил это в начале
Подробнее здесь: https://stackoverflow.com/questions/794 ... p-of-tiles
Мобильная версия