Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

How can you adjust the UV rect (aka tiling / offset) of a UI Sprite Image?

Discussion in 'Unity UI (uGUI) & TextMesh Pro' started by Essential, Dec 2, 2014.

  1. Essential

    Essential

    Joined:
    Sep 8, 2011
    Posts:
    265
    How can you adjust the tiling and offset of a UI Sprite Image?

    The controls are exposed in the Inspector for the RawImage but not for a Sprite Image. I've tried adding a material but that doesn't seem to work either.
     
  2. Essential

    Essential

    Joined:
    Sep 8, 2011
    Posts:
    265
    Bump? Seems like a pretty simple thing. :)
     
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,084
    The sprite shaders don't support it. It's not something that would be compatible with a sprite atlas anyway.

    --Eric
     
  4. Essential

    Essential

    Joined:
    Sep 8, 2011
    Posts:
    265
    Oh I see. I guess that explains why I couldn't do it. Although it's strange that they don't support it as the renderer itself has a tiled option.
     
  5. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,087
    If you use a RawImage you can control this. The reason it's not supported is that the sprite may be packed and we generate internal tiling ext for tiled sprites using extra verts.
     
  6. Essential

    Essential

    Joined:
    Sep 8, 2011
    Posts:
    265
    I see. Thanks for the clarification Tim.
     
  7. laggyluk

    laggyluk

    Joined:
    Oct 7, 2011
    Posts:
    32
    Hi
    I used RawImage like described here for similiar purpose, to be able to scroll the texture. When I adjust the UVRect in editor it's scrolling alright but when doing it from code there's no visual difference, can see values are changing in editor though. Does it need some additional update method to be refreshed with new values?
     
  8. laggyluk

    laggyluk

    Joined:
    Oct 7, 2011
    Posts:
    32
    ok nevermind, value I add to uv needs scaling down