Unity-Select-Units-Within-Rectangle-Tutorial icon indicating copy to clipboard operation
Unity-Select-Units-Within-Rectangle-Tutorial copied to clipboard

Unity tutorial on how to select units within rectangle

Select units within rectangle

Source code for Unity tutorial on how to select units within rectangle. Notice that the code is not exactly as in the tutorial because I've learned one or two things but the idea is the same. The main difference you should change is that border of the selection square has to be 2 pixels wide, or you will see some flickering.

Closest point on line segment

YouTube video showing the result:

Select units in Unity video

Link to the tutorial: https://www.habrador.com/tutorials/select-units-within-rectangle/

If you also want to highlight the units you selected with some rectangle around it, the idea is basically the same. This is a good tutorial on the topic: https://www.youtube.com/watch?v=2Tgqr1_ajqE