您的位置:首页 > 产品设计 > UI/UE

UGUI自由缩放

2018-03-27 11:52 274 查看
整体思路是这样的,首先,整个功能是使用unity的IBeginDragHandler,IDragHandler接口来实现,通过对点的拖动,根据鼠标位置重新计算图片大小及坐标。
右侧点的拖动:private void Right()
{
if (startWidth + Input.mousePosition.x - startMouseX <= minWidth)
return;

gameObject.GetComponent<RectTransform>().sizeDelta = new Vector2(startWidth + Input.mousePosition.x - startMouseX, gameObject.GetComponent<RectTransform>().sizeDelta.y);
gameObject.transform.localPosition = new Vector3(startRectX + (gameObject.GetComponent<RectTransform>().sizeDelta.x - startWidth) / 2, gameObject.transform.localPosition.y);
}资源已上传CSDN下载,链接:
https://download.csdn.net/download/n_moling/10310821
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Unity UGUI 自由变换