首页 > 其他 > 详细

RectTransformUtility.ScreenPointToWorldPointInRectangle使用说明

时间:2018-07-22 23:02:23      阅读:182      评论:0      收藏:0      [点我收藏+]

首先,看Unity Scripting API上的介绍:

public static bool ScreenPointToWorldPointInRectangle(RectTransform rect, Vector2 screenPoint, Camera cam, out Vector3 worldPoint);
描述:
将屏幕空间上的点转换为位于给定RectTransform平面上的世界空间中的位置。cam参数应该是与屏幕点相关的相机。对于Canvas设置为“Screen Space - Overlay mode”模式的情况,cam参数应该为null。

 

示例:Vector2 position;

           RectTransformUtility.ScreenPointToWorldPointInRectangle(GameObject.Find("Canvas").transform as RectTransform,Input.GetmousePosition,null,out positoin) // 将当前所在像素坐标的鼠标位置转换为Canvas物体所在平面上的世界空间中的位置,将位置信息返回给position

RectTransformUtility.ScreenPointToWorldPointInRectangle使用说明

原文:https://www.cnblogs.com/Dearmyh/p/9351706.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!