public class Controller : MonoBehaviour
private LineRenderer lineRenderer;
private bool isMouseDown;
private Vector3 leftUpPoint;
private Vector3 rightUpPoint;
private Vector3 leftDownPoint;
private Vector3 rightDownPoint;
lineRenderer = this.GetComponent();
private void SelSoldier()
if (Input.GetMouseButtonDown(0))
leftUpPoint = Input.mousePosition;
else if (Input.GetMouseButtonUp(0))
lineRenderer.positionCount = 0;
rightDownPoint = Input.mousePosition;
leftDownPoint = new Vector3(leftUpPoint.x,rightDownPoint.y,z);
rightUpPoint = new Vector3(rightDownPoint.x,leftUpPoint.y,z);
lineRenderer.positionCount = 4;
lineRenderer.SetPosition(0,Camera.main.ScreenToWorldPoint(leftUpPoint));
lineRenderer.SetPosition(1,Camera.main.ScreenToWorldPoint(rightUpPoint));
lineRenderer.SetPosition(2, Camera.main.ScreenToWorldPoint(rightDownPoint));
lineRenderer.SetPosition(3,Camera.main.ScreenToWorldPoint(leftDownPoint));