public static SnapResult Snap(List <GameObject> roots, Config snapConfig) { float minSnapDistance = float.MaxValue; SnapResult bestResult = new SnapResult(SnapFailReson.NoDestinationFound); foreach (var root in roots) { var snapResult = CalculateSnapResult(root, snapConfig); if (snapResult.FailReason == SnapFailReson.MaxObjectsExceeded) { return(snapResult); } else if (snapResult.FailReason == SnapFailReson.None) { if (snapResult.SnapDistance < minSnapDistance) { minSnapDistance = snapResult.SnapDistance; bestResult = snapResult; } } } if (bestResult.Success) { ObjectSnap.Snap(roots, bestResult.SnapPivot, bestResult.SnapDestination); } return(bestResult); }
public static SnapResult Snap(GameObject root, Config snapConfig) { var snapResult = CalculateSnapResult(root, snapConfig); if (snapResult.Success) { ObjectSnap.Snap(root, snapResult.SnapPivot, snapResult.SnapDestination); } return(snapResult); }