void PushVecocityShape() { if (select == null) { if (Input.GetMouseButtonDown(0)) { ShapeObject[] shapes = ShapesCollision.OverlapPoint(mousePoint); if (shapes.Length <= 0) { return; } select = shapes[0]; } } else { mouseOffset = mousePoint - select.Position; text.text = mouseOffset.magnitude.ToString(); text.transform.position = mousePoint; Debug.DrawLine(select.Position, mousePoint); if (Input.GetMouseButtonUp(0)) { select.Velocity = (-mouseOffset); select = null; } } }
void DragShape() { if (select != null) { select.Position = mouseOffset + mousePoint; select.SetColor(Color.white); select.RigidbodyType = RigidbodyType.Kinmatic; } else { ShapeObject[] shapes = ShapesCollision.OverlapPoint(mousePoint); if (shapes.Length <= 0) { return; } if (shapes[0].RigidbodyType == RigidbodyType.Static) { return; } select = shapes[0]; selectType = select.RigidbodyType; mouseOffset = select.Position - mousePoint; } }
void OverlapCheck() { //Overlap Check ShapeObject[] shapes = ShapeQuadTree.OverlapRect(mousePoint, checkRegion); foreach (var shape in shapes) { shape.SetColor(Color.black * 0.8f); } checkAngle += Input.mouseScrollDelta.y * 5; ShapeObject[] overlap = ShapesCollision.OverlapRectangle(mousePoint, checkAngle, checkRegion); foreach (var shape in overlap) { shape.SetColor(Color.white); } text.text = overlap.Length.ToString(); text.transform.position = new Vector3(mousePoint.x, mousePoint.y); }
void RayCastCheck() { if (Input.GetMouseButtonDown(1)) { lineOrigin = mousePoint; } Vector3 dirction = mousePoint - lineOrigin; ShapeObject[] shapes = ShapeQuadTree.OverlapLine(lineOrigin, dirction); foreach (var shape in shapes) { shape.SetColor(Color.black * 0.8f); } shapes = ShapesCollision.RayCast(lineOrigin, dirction); foreach (var shape in shapes) { shape.SetColor(Color.white * 0.8f); } text.text = shapes.Length.ToString(); text.transform.position = lineOrigin; }