/// <summary>
/// 相机
/// </summary>
public Camera m_Camera;
/// <summary>
/// UI按钮
/// </summary>
public RectTransform UIBtn;
void Update()
{
//坐标转换 世界转屏幕
Vector2 screenPoint = RectTransformUtility.WorldToScreenPoint(m_Camera, transform.position);
Vector2 localPoint;
//坐标转换 屏幕转UI
if (RectTransformUtility.ScreenPointToLocalPointInRectangle(canvasTran, screenPoint, m_Camera, out localPoint))
{
UIBtn.anchoredPosition = localPoint;
}
}
unit 模型的位置坐标转换到UI坐标
最新推荐文章于 2024-03-27 09:50:19 发布