Search Unity

Tilemap displaying tiles incorreectly.

Discussion in '2D' started by eightvo8080, Oct 2, 2019.

  1. eightvo8080

    eightvo8080

    Joined:
    Oct 2, 2019
    Posts:
    2
    Code (CSharp):
    1.      
    2. public override void GetTileData(Vector3Int pos, ITilemap map, ref TileData tileData)
    3.         {
    4.             bool vocal = true;
    5.             var mask = map.GetBlobMask(pos, Priority,vocal);
    6.             TileIndex = GetTileIndex(mask);
    7.             int rotCnt = GetTileRotationCount(mask);
    8.             var a = 0;
    9.             switch(rotCnt)
    10.             {
    11.                 case 0:
    12.                     a = 0;
    13.                     break;
    14.                 case 1:
    15.                     a = 270;
    16.                     break;
    17.                 case 2:
    18.                     a = 180;
    19.                     break;
    20.                 case 3:
    21.                     a = 90;
    22.                     break;
    23.             }
    24.             if (vocal)
    25.             {
    26.                 Debug.Log($"({pos.x}, {pos.y}) mask: {mask} {rotCnt} => {a} deg");
    27.             }
    28.             tileData.transform = Matrix4x4.Rotate(Quaternion.Euler(0, 0, a));
    29.             if (TileIndex == -1) tileData.sprite = null;
    30.             else
    31.                 tileData.sprite = _sprites[TileIndex];
    32.         }
    33.  
    Notice how it says both tiles should be rotated? The Tile at (3,3) is visually displayed without any rotation. The tile at (4,3) is displayed correctly rotated 90 degrees.

    In any case, regardless of how the original image is oriented... it should be impossible for the same image to be shown rotated at 90 and 270 degrees and appear as it does in this output.