Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuleTile graphical rendering bug with SetTilesBlock() in Unity 2021+ #324

Open
aroman opened this issue Nov 23, 2021 · 2 comments
Open

RuleTile graphical rendering bug with SetTilesBlock() in Unity 2021+ #324

aroman opened this issue Nov 23, 2021 · 2 comments

Comments

@aroman
Copy link

aroman commented Nov 23, 2021

Hi,

There seems to be a rendering bug with 2d-extras, such that depending on the API used to programmatically set TileMap data from a script, the RuleTiles may appear "invisible".

In short, this code results in the tiles which are visible:

for (var x = 0; x < 10; x++)
{
    for (var y = 0; y < 10; y++)
    {
        var position = new Vector3Int(x, y, 0);
        someTileMap.SetTile(position, someTile);
    }
}

This code, however, does not:

var area = new BoundsInt(Vector3Int.zero, new Vector3Int(10, 10, 1));
var tileArray = new TileBase[area.size.x * area.size.y * area.size.z];
for (var i = 0; i < tileArray.Length; i++)
{
    tileArray[i] = someTile;
}
someTileMap.SetTilesBlock(area, tileArray);

Now, what's very strange is that both snippets work correctly if someTile is a regular Tile, rather than a RuleTile. )In practice, the type of someTile is TileBase, and I provide it from the inspector.)

To be clear: in BOTH cases, the Tile data is being set in the TileMap. In fact, this can be confirmed graphically with the palette editor, which will change the brush preview correctly based on the underlying Tilemap data (see 1:48 in the video demonstration I linked below). The issue is, those tiles do not appear in either the game view, scene view, or built projects.

I made a brief video to demonstrate the bug: https://www.youtube.com/watch?v=uarGP83B5hQ

@aroman aroman changed the title RuleTile rendering bug with SetTilesBlock() RuleTile graphical rendering bug with SetTilesBlock() Nov 23, 2021
@aroman
Copy link
Author

aroman commented Nov 24, 2021

As an update, I've confirmed that this issue is only present in Unity 2021 and 2022, but NOT on 2020. Latest versions of all of those release trains.

@aroman aroman changed the title RuleTile graphical rendering bug with SetTilesBlock() RuleTile graphical rendering bug with SetTilesBlock() in Unity 2021+ Nov 24, 2021
aroman added a commit to aroman/2d-extras that referenced this issue Nov 24, 2021
@ChuanXin-Unity
Copy link
Collaborator

Thanks! I posted an update on this issue at https://forum.unity.com/threads/2021-2-0f1-tilemap-settiles-not-working-as-previous.1190572/#post-7682245, and hopefully will be able to confirm a fixed version for 2021.2 soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants