How can I select players like rts with the gui box is a 2d game

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class selectable : MonoBehaviour {

Rect rect;
Vector2 SM;
Vector2 EM;
public Texture aTexture;
public script Player;

// Use this for initialization
void Start ()
{

}

// Update is called once per frame
void Update ()
{

rect = new Rect(SM.x, Screen.height - SM.y , EM.x - SM.x, - ((Screen.height - SM.y) - (Screen.height - EM.y)));

if(Input.GetMouseButtonDown(0))
	{
		SM = Input.mousePosition;
	}
	if(Input.GetMouseButton(0))
	{
		EM = Input.mousePosition;
	}
	if(Input.GetMouseButtonUp(0))
	{
		SM = Vector2.zero;
		EM = Vector2.zero;
	}
}

void OnGUI () {
	if(SM != Vector2.zero && EM != Vector2.zero)
	{

		GUI.DrawTexture(rect, aTexture);
	}

}
}

First Google result: