Search Unity

How would you do a box select

Discussion in 'Scripting' started by Sean-Powell, Aug 4, 2015.

  1. Sean-Powell

    Sean-Powell

    Joined:
    Dec 18, 2014
    Posts:
    87
    The way i though about doing would be get the mouse position when the mouse clicks and then get the mouse position when the button is released. Then just re-sizing a cube between those positions, then just doing a simple collider. I know how to do all of that except re-sizing the cube how would that be achieved? if there is a better way please tell me thanks.
     
  2. Daso1970

    Daso1970

    Joined:
    Aug 3, 2015
    Posts:
    9
    Calculate the Vector3 that is right in the middle of the down and up Vector3s and place the cube there. Then you can just set the localScale of the cube to the difference between the down and up Vector3s (example: x should be scaled to 10 if there is 10 between down's x-position and up's x-position).
     
  3. Sean-Powell

    Sean-Powell

    Joined:
    Dec 18, 2014
    Posts:
    87
    ok thanks