public void Update() { Vector2 circlePos = GetV2(_circlePosTrans); //float rectX = _rect.x; //float rectY = _rect.y; //float rectWidth = _rect.width; //float rectHeight = _rect.height; //float circleX = circlePos.x; //float circleY = circlePos.y; //float nearestX = Mathf.Max(rectX, Mathf.Min(circleX, rectX + rectWidth)); //float nearestY = Mathf.Max(rectY, Mathf.Min(circleY, rectY + rectHeight)); //_nearestPos = new Vector2(nearestX, nearestY); _nearestPos = Math2d.GetNearestRectPoint(circlePos, _rect); _isOverlap = Math2d.IsCircleRectOverlap(circlePos, _radius, _rect); _nearestPosTrans.position = new Vector3(_nearestPos.x, 0, _nearestPos.y); }