1.ScreenPointToLocalPointInRectangle(RectTransform rect, Vector2 screenPoint, Camera cam, out Vector2 localPoint);
这个屏幕坐标在矩形内的相对位置,out localPoint是返回值,返回的是一个localPosition,如下图

//
//
2.ScreenPointToWorldPointInRectangle(RectTransform rect, Vector2 screenPoint, Camera cam, out Vector3 worldPoint);
这个屏幕坐标转成世界坐标,返回的是一个3d世界坐标。因为屏幕坐标需要一个屏幕,这个矩形就是作为屏幕。
该文章介绍了Unity3D中的两个函数,用于处理屏幕坐标与游戏对象坐标之间的转换。ScreenPointToLocalPointInRectangle函数将屏幕坐标转换为RectTransform矩形内的局部坐标,而ScreenPointToWorldPointInRectangle则将屏幕坐标转化为3D世界坐标,这两个方法都涉及到Camera参数,并返回转换后的坐标值。
6646

被折叠的 条评论
为什么被折叠?



