Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Zoom/Scale ScrollRect Image

Discussion in 'Immediate Mode GUI (IMGUI)' started by ntwinter, Nov 17, 2014.

  1. ntwinter

    ntwinter

    Joined:
    Oct 24, 2013
    Posts:
    14
    I have an image in a scrollrect that has a mask applied so that not all of the image is visible.
    The image is displayed at it's native size within the masked scrollrect.
    I'd like to add some sort of zoom/scale function to the image so that the user is able to zoom out so the image fits into the mask area (effectively shrinking the image until both h or w fits the mask extents).
    I'm happy for this to be by use of a slider in the GUI or by use of the middle mouse button.
    I don't think there is a need to scale greater than the images native size, only to 'reduce' the size by given amounts until it fits into the masked area.
    I'm not great with scripting so I'll need some holding of hands on this one if it gets tricky.

    Cheers.