Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

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