Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: JazzMasta on September 25, 2014, 03:57:39 AM
-
How do you get the width/height of a UISprite and touch/position?
I'm want something like this (psuedo code):
float percentX = touch.x / width;
float percentY = touch.y / height;
-
Touch position is in screen space. You need to transform from screen space to world space, then from world space to local space (relative to widget.transform.parent). You then get widget.localCorners, where corner[0] is bottom left and corner[2] is top-right. So (transformedTouchPosition - corner[0]) / (corner[2] - corner[0]).