コード例 #1
0
 // called when left mouse is first pressed down, creates a new rectangle and passes it to
 // BoxSelectionCheck. Clears current selection if left ctrl not down.
 public void BeginBoxSelection(Vector3 initMousePos)
 {
     // if ctrl is not being held down
     if (!Input.GetKey("left ctrl"))
     {
         OnClearSelection?.Invoke();
     }
     this.mousePos1 = initMousePos;
     this.mousePos2 = initMousePos;
     selectRect     = new Rect(mousePos1.x, mousePos1.y, mousePos2.x - mousePos1.x, mousePos2.y - mousePos1.y);
     OnBoxSelection?.Invoke(selectRect);
 }
コード例 #2
0
 // called when left click released, creates a new rectangle for BoxSelectionCheck.
 // (commented out code edits existing rectangle. Doesn't work for some reason. Might change later for performance?)
 public void EndBoxSelection(Vector3 mousePos2)
 {
     this.mousePos2 = mousePos2;
     selectRect     = new Rect(mousePos1.x, mousePos1.y, mousePos2.x - mousePos1.x, mousePos2.y - mousePos1.y);
     OnBoxSelection?.Invoke(selectRect);
 }
コード例 #3
0
 // called while left click remains down, creates a new rectangle for BoxSelectionCheck.
 // (commented out code edits existing rectangle. Doesn't work for some reason. Might change later for performance?)
 public void ContinueBoxSelection(RaycastHit rayHit, Vector3 mousePos2)
 {
     this.mousePos2 = mousePos2;
     selectRect     = new Rect(mousePos1.x, mousePos1.y, mousePos2.x - mousePos1.x, mousePos2.y - mousePos1.y);
     OnBoxSelection?.Invoke(selectRect);
 }