RectTransformUtility.ScreenPointToLocalPointInRectangle 从屏幕点到矩形内的本地点
屏幕空间点转换为矩形变换内部的本地位置,该点在它的矩形平面上。
该cam 参数应该是该相机关联的屏幕点。对于在画布上的矩形变换设置该屏幕空间为-Overlay模式,cam 参数应该为空。
当ScreenPointToLocalPointInRectangle从事件处理器内部提供一个PointerEventData对象被使用时,相机可以通过使用PointerEventData.enterEventData(为悬停功能)或者 PointerEventData.pressEventCamera(为单击功能)被获取。该函数将会自动对指定事件使用正确的相机(或者空)。
返回值 bool类型是判断此点是否在Rect所在的平面上
public static bool ScreenPointToLocalPointInRectangle(RectTransform rect, Vector2 screenPoint, Camera cam, out Vector2 localPoint);
unity3D笔记之十四 屏幕坐标转UI坐标 ScreenPointToLocalPointInRectangle
最新推荐文章于 2025-02-15 03:54:37 发布