if (Input.GetMouseButtonDown (0))
{
selectArea.gameObject.SetActive (true);
Debug.Log (Input.mousePosition);
lastPos = Input.mousePosition;
}
if (selectArea.gameObject.activeSelf)
{
Vector2 offsetPos = Input.mousePosition - lastPos;
if (offsetPos.x > 0 && offsetPos.y > 0)
{
selectArea.pivot = new Vector2 (0, 0);
}
else if (offsetPos.x < 0 && offsetPos.y > 0)
{
selectArea.pivot = new Vector2 (1, 0);
}
else if (offsetPos.x < 0 && offsetPos.y < 0)
{
selectArea.pivot = new Vector2 (1, 1);
}
else if (offsetPos.x > 0 && offsetPos.y < 0)
{
selectArea.pivot = new Vector2 (0, 1);
}
selectArea.anchoredPosition = lastPos;
selectArea.sizeDelta = new Vector2 (Mathf.Abs (offsetPos.x), Mathf.Abs (offsetPos.y));
}
if (Input.GetMouseButtonUp (0))
{
selectArea.gameObject.SetActive (false);
selectArea.sizeDelta = Vector2.zero;
}
UGUI选框程序
最新推荐文章于 2022-09-26 16:42:01 发布