Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question SpriteRenderer doesn't tile from a pivot point

Discussion in '2D' started by Cameo221, Oct 17, 2023.

  1. Cameo221

    Cameo221

    Joined:
    Aug 2, 2018
    Posts:
    36
    Hi, I've been trying to use the SpriteRenderer to loop a sprite.
    This image is how I have it configured, where the DrawMode is Tiled and the TileMode is Continuous.
    upload_2023-10-16_23-4-12.png

    As I adjust the size, it appears to expand off the bottom-left of the sprite renderer, no matter what sprite pivot I have configured, no matter if it's (0,0), (0, 0.5), (0, 1), etc.

    For example, if my sprite pivot were in the top right (1, 1), I would expect it would look like this:
    upload_2023-10-16_23-8-19.png

    Instead, the SpriteRenderer looks like this: (note how it appears to originate from the bottom left)
    upload_2023-10-16_23-8-34.png

    I've tried experimenting with different DrawModes and a different TileMode, but it doesn't match exactly what I'm expecting. I would have hoped that having different sprite pivots impacts the origin from which the tiled SpriteRenderer begins expanding, but I have not had success.

    What might be the best solution to this problem if there is one, or if I should be attempting to approach this from a different angle entirely?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    37,112
    Wow, today I learned... I did not believe you so I went to check what's going on, but you are 100% correct:

    The sprite pivot point does not work "as you might expect" in Tiled draw modes.

    But I'll tell you how it is working: whatever pivot you set for the sprite itself, the Tiled rendering of that sprite uses that pivot, but it applies it across the ENTIRE final tiled area.

    Try it yourself: make a small 64x64 sprite, import size to 64 PPU, then drop it in the scene.

    Tile it to perhaps 3x1 and try setting the pivot to lower left (0,0). Now try setting the pivot to upper right, then center.

    See how the clump of 3x1 tiles moves around as you change the pivot? It might help to see it if you make a small 3D cube at (0,0,0) and put your sprite at (0,0,0) as well.

    In any case, it does make sense... but it would require a bit more fiddling. I would probably just keep the pivot lower left (0,0) for tiled sprites.
     
    Cameo221 likes this.
  3. Cameo221

    Cameo221

    Joined:
    Aug 2, 2018
    Posts:
    36
    Yeah, I have decided to be okay with just the bottom left as being the point of expansion.

    Adjusting the pivot of the sprite does appear to shift it around.
    That tells me that it may not be the responsibility of the pivot to direct the sprite renderer as to where it should expand from.
    I guess it's just unfortunate that I can't have control over that unless I try a more complex solution.

    I've tried fiddling with using shaders/material to solve the problem, but it's a bit out of my personal scope and knowledge base to delve into it.

    Appreciate the response!