Search Unity

Question How can I update the tiles, tilemaps, the palette and the viewport in Unity?

Discussion in '2D' started by Shellcial, Feb 18, 2021.

  1. Shellcial

    Shellcial

    Joined:
    Jan 9, 2021
    Posts:
    12
    Unity Version: 2019.4.18f1

    Image I am referring: https://ibb.co/album/XZkDZJ sorry that I can't directly insert image here, I don't why but the inserted image just show a crossed icon.

    I want to update the tiles in Unity, for example, I have a "Player" sprite and tile which is a blue circle.

    (image1)

    Then, I want to replace it as a red square. I found that I can directly replace the image file in the folder. thenthe tilemap palette, the viewport also update the "Player" to become red square, which is good.


    (image2)
    (image3)

    Then, I try the same method on tilemap. I import a tilemap, then directly put it into the palette, saving asset into "Tiles" folder.

    (image6)

    There are blue circle and red circle. Then, I replace the tilemap, the sprite of blue circle and red circle are replaced by a blue man and red man while keeping they have the same position on the tilemap.

    (image8)

    Then the tilemap, the tiles, the palette, even the map I created in the viewport also updated correctly, this is very good.

    However, I find another issue if I want to do this with another approach.

    First, I called the blue person sprite as "Player1", the red person sprite as "Player2".

    (image9)

    Next I rename the sprite, I make the green and red circle as the "Player1" and "Player2".

    (image14)

    However, the sprite has been updated, but the tiles, palette and the map I created in the viewport doesn't update.

    (image15)

    Then, the weirdest thing is if I rename the "Player1" and 2 to the original blue and red man sprite,

    (image16)

    The "Player 1" and "Player 2" will become the red and green circle!

    (image17)

    The sprite in tilemap and asset in tiles also show the "Player 1" and "Player2" are the blue and red man. but the palette and the map in viewport has been changed...and the green and red circle are deleted in the palette. I can recreate this situation every time and I wonder is this also an issue to others? I am curious is there a way to update the sprite inside Unity although at least I can replace the entire tilemap if I want to update the sprite.
     
    Last edited: Feb 18, 2021
  2. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Hi, when renaming the Sprites, does the Tile asset update to use the renamed Sprite?
    upload_2021-2-19_10-8-57.png

    If the Tile Asset is updated correctly, you could try refreshing all the Tiles in the Tilemap to use the new Sprite:
    upload_2021-2-19_10-8-37.png

    Let us know if that helps!
     
  3. Shellcial

    Shellcial

    Joined:
    Jan 9, 2021
    Posts:
    12
    When I changed the sprite name, Tile Asset is not updated, I have tried to manually update it - drag the sprite into the palette and replace the tile asset, but the map in viewport won't update.
     
  4. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Were the original Sprites deleted in the Sprite Editor? Changing the name of another Sprite to the same name does not change the Sprite reference used in the Tile asset. This can be rather confusing in terms of Sprite asset management. It is better to change the Sprite used in the Tile asset rather than renaming a Sprite.

    This would work if you selected "Reuse" when dragging the Sprite into the Tile Palette and selecting the directory where the Tile assets originally were.
     
  5. Shellcial

    Shellcial

    Joined:
    Jan 9, 2021
    Posts:
    12
    okay, so this means I cannot change the sprite name to redirect the tile reference, and I need to change the reference sprite image itself so that the tile asset will also update correctly? Since I have two tilemaps as the below example, and I found that if I replace the whole tilemap - replace the entire left image by right image in the tilemap folder. And in Unity the two men are replaced by two circles.
    5.PNG

    So the above example is changing the sprite image through replacing the whole tilemap. But is there another way to change a specific sprite of a tilemap in Unity? For example, I have one tilemap and one extra texture inside Unity.

    And I want to drag the blue circle into the palette to replace the blue man. 6.PNG
    So I replace its tile assets.
    7.PNG

    but the blue man in the map does not update.
    8.PNG

    So this means the blue man in the map is still using the original sprite reference even the tile asset has changed? In this situation what should I do? Is it modifying the tilemap in drawing software and replace the entire tilemap would be the only option I can do for this case?
     
  6. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    Thanks for the update! I understand better what is going on. When you drag in the Blue Circle Sprite and replace the original Tile Asset, this creates a new Tile Asset and removes the original. The Tilemap still refers to the original Tile Asset, so it does not update automatically. This is not made clear to you as the user unfortunately, so we will look into this issue.

    In the meantime, to update the Sprite, you will need to change it directly in the Tile asset.