标签:
世界空间中的点坐标转换到屏幕坐标:
screenPos = RectTransformUtility.WorldToScreenPoint(cam, worldPos.transform.position);
UGUI物体的坐标转换到屏幕坐标:
screenPos = RectTransformUtility.WorldToScreenPoint(canvas.worldCamera, uguiObj.transform.position);
屏幕坐标转换到UGUI坐标:
Vector3 worldPoint;
if (RectTransformUtility.ScreenPointToWorldPointInRectangle(rectTrans, camPos, canvas.worldCamera,out worldPoint))
{
transform.position = worldPoint;
}
屏幕坐标转换到世界空间坐标(射线碰撞位置):
var ray = RectTransformUtility.ScreenPointToRay(worldCamera, screenPos);
RaycastHit hitInfo;
if (Physics.Raycast(ray, out hitInfo))
{
pos.transform.position = hitInfo.point;
}
标签:
原文地址:http://www.cnblogs.com/fuliufuliu/p/5094557.html