SHARE
TWEET

Untitled

a guest Mar 18th, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public bool IsWithinSelectionBounds(GameObject gameObject)
  2.     {
  3.         if (!isSelecting)
  4.             return false;
  5.  
  6.         var camera = Camera.main;
  7.         Vector2 currentMousePosition = new Vector2(camera.ScreenToWorldPoint(Input.mousePosition).x, camera.ScreenToWorldPoint(Input.mousePosition).y);
  8.         Vector2 beginningMousePosition = new Vector2(camera.ScreenToWorldPoint(mousePosition1).x, camera.ScreenToWorldPoint(mousePosition1).y);
  9.         Rect rect = new Rect(beginningMousePosition.x, beginningMousePosition.y, currentMousePosition.x, currentMousePosition.y);
  10.  
  11.         Debug.Log(rect.Contains(gameObject.transform.position));
  12.  
  13.         return rect.Contains(gameObject.transform.position);
  14.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top