Search Unity

How do I tile a 2D OBJECT, not a SPRITE?

Discussion in '2D' started by GameCreator405, Jan 18, 2022.

  1. GameCreator405

    GameCreator405

    Joined:
    Jun 17, 2021
    Posts:
    15
    In other words, I do I give an individual object the function of the tile draw mode in a Sprite Renderer. Since I use a specific corner rounding technique in my tiles and need to make specific game elements, I need them to be individual, destructible objects and not extended versions of a single sprite.
    Is there an effective way to do this without placing the tiles individually?
     
  2. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,511
    Not totally sure what you're going for, an illustration might help, but if I understand right you might be able to accomplish what you want using tiles and a custom shader/material.
    d - Copy.png
    If you were to use a sprite with a texture (ColorTex) set to Repeat mode then tiles on this tilemap should behave like a tile draw mode SpriteRenderer, but it'll draw the repeated texture on the shapes (from MainTex) that you provide from your tilemap, including rounded corners.

    You'll need to assign a tilemap this material. The shapes for your tiles use can be white or whatever since we're not using its color, we're just mining them for their alpha. We pull the colors from the repeat-mode texture.

    You'd destroy part of it by nulling it out via tilemap.SetTile().

    But there's a good chance I'm misunderstanding what you want. If so, you need to illustrate since 2D games and artistic objectives can be very diverse.
     
    Last edited: Jan 23, 2022