【发布时间】:2019-08-12 20:31:04
【问题描述】:
我正在使用.GetWorldCorners 来查找棕榈树图像的右上角和左下角。但是,我返回的值与实际角落不同。此外,当我移动Image 时,角会改变位置,远离Image,而不是与它完全一起移动。我试过transform.postion 有同样的问题。
private void OnDrawGizmos()
{
Vector3[] corners = new Vector3[4];
GetComponent<RectTransform>().GetWorldCorners(corners);
var bottomLeft = corners[0];
var topRight = corners[2];
Gizmos.color = new Color(0, 1, 0, 0.5f);
Gizmos.DrawCube(topRight, bottomLeft);
//Gizmos.DrawCube(new Vector2(this.transform.position.x - 0.5f, this.transform.position.y + 0.5f), new Vector2(this.transform.position.x + 0.5f, this.transform.position.y - 0.5f));
}
【问题讨论】: