You should look at
https://docs.unity3d.com/ScriptReference/Collider.ClosestPointOnBounds.html
or just
https://docs.unity3d.com/ScriptReference/Bounds.ClosestPoint.html
↧