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. Dismiss Notice

Pan background

Discussion in 'UGUI & TextMesh Pro' started by SunnySunshine, Sep 18, 2014.

  1. SunnySunshine

    SunnySunshine

    Joined:
    May 18, 2009
    Posts:
    952
    Is it possible to pan an UI element's image while keeping its position? Kinda like offsetting the UV.
     
  2. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,181
    https://gist.github.com/stramit/46d26840b265efba8792

    If you look at the gist above you will see an example for how we do "Shadow". What you will want to do is take this and instead of duplicating the passed in verts, just offset the UV's by some value / time (might not want to use a packed sprite here as it might mess up). Add an update function and call SetVertices dirty each frame on the attached Graphic and you should be good to go :)
     
    SunnySunshine likes this.
  3. SunnySunshine

    SunnySunshine

    Joined:
    May 18, 2009
    Posts:
    952
    Thanks. I managed to pan the image, but it does not seem to repeat (like css repeat-x, repeat-y). Can this be done?
     
    Last edited: Sep 18, 2014
  4. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,181
    What are the import settings on the texture? They need to be set to repeat and not clamp.
     
  5. SunnySunshine

    SunnySunshine

    Joined:
    May 18, 2009
    Posts:
    952
    It is configured to be a sprite/UI element. I don't see any option to configure clamp/repeat:

     
  6. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,181
    Change type to advanced :) If you set it to 'sprite' first it will preserve all the default sprite settings when you open the advanced mode.
     
    SunnySunshine likes this.
  7. SunnySunshine

    SunnySunshine

    Joined:
    May 18, 2009
    Posts:
    952
    Ah, so simple. Thanks!