2D circular image carousel help!!!
Hi - I'm a unity noob, & hoping someone can help me out...
here's my hierarchy:
  scene
       camera
       event system
       canvas
       carousel game object
            left "image button"
                 image
                 button
            mask panel
                 container panel
                      image 1
                      image 2
                      image 3
                      image 4
            right "image button"
                 image
                 button
 
               the images all have the same image size in pixels before being imported & added to the scene.
there is only 1 script component on the carousel game object.
the mask panel is wide enough to only show 3 of the images on start.
the left & right buttons move the container panel left & right:
  this is handled in the carousel.cs -> Update() method.
  the container is translated by (Vector3.left/right * 1) in the direction corresponding to the held button.
 
               the carousel needs to be "circular", i.e.,
 if the left button is held down
     once the 4th image's right edge is left of the mask panel's right edge
         the 1st image should be scrolling into view.
 
               using moving left as an example, my idea is thus:
 OnUpdate
     *if 1st image's right edge is to the left of the mask panel's left edge*
         expand the container panel's width to the right by the width of the 1st image
         move the 1st image to the newly made space in the container
         contract the container panel's width from the left by the width of the 1st image
         update the list of the order of the images in the container
 
               I'm having trouble with the if pseudocode between the asterisks. I can't seem to figure out the x-position & width of the image, & the x-position of the mask panel, using the same coordinate system, in order to detect that the right edge of the image is to the left of the left edge of the mask panel.
can anyone give me a hand?
Thanks in advance!
Your answer