【发布时间】:2015-06-17 18:40:19
【问题描述】:
有谁知道如何在 Unity 中将像素坐标转换为 UI 坐标,反之亦然?例如,假设我想用鼠标单击屏幕上的某个位置,并且 UI 图像位于该单击位置。如果我这样做是行不通的:
Image img = null // I assign it via the inspector
void Update()
{
if(Input.GetMouseButtonDown(0))
{
img.rectTransform.anchorPosition = Input.mousePosition;
}
}
【问题讨论】: