ControllerImage.SetActive(true);
Vector2 outVec;
if (RectTransformUtility.ScreenPointToLocalPointInRectangle(canvasRect, Input.mousePosition, null, out outVec))
{
if (mousePos.x < Screen.width - imageSizeX && mousePos.y > imageSizeY)
{
print("刚好");
ControllerImage.GetComponent<RectTransform>().anchoredPosition = outVec;
}
else
{
if (mousePos.x >= Screen.width - imageSizeX)
{
print("X不够了" + mousePos);
float leftMove = imageSizeX - (Screen.width - mousePos.x);
outVec = new Vector3(outVec.x - leftMove, outVec.y);
}
if (mousePos.y < imageSizeY)
{
print("y不够了" + mousePos);
float topMove = imageSizeY - mousePos.y;
outVec = new Vector3(outVec.x, outVec.y + topMove);
}
ControllerImage.GetComponent<RectTransform>().anchoredPosition = outVec;
}
}
右键管理菜单
最新推荐文章于 2025-03-13 15:25:54 发布