Author Topic: UITexture pinch zoom & panning  (Read 1643 times)

zyap

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
UITexture pinch zoom & panning
« on: May 22, 2015, 04:43:11 PM »
Hi guys,
I have a UITexture that is a child of a UIScrollView, and I have the scroll view's movement to be unrestricted so that i can 1 touch drag the image around. What I would like to achieve is the ability to zoom based on the midPoint of the 2 finger touches. This is the code that does that:

midPoint = new Vector2(((Input.GetTouch(0).position.x + Input.GetTouch(1).position.x)/2), ((Input.GetTouch(0).position.y + Input.GetTouch(1).position.y)/2));

What I'm having trouble is to actually have the image zoom in/out base on that midPoint vector.

Is there an easier way to do this?

Currently upon runtime, my code instantiates an empty gameobject and make that the UITExture's parent. This allows me to create custom pivot as NGUI doesnt allow that.