How to snap objects in game

I been looking for some script for assembly objects in a puzzle 3d game, my original idea is make this parent emptys to the big objects & add the snap script for this empty, with this build a bigger object.
this is an example what I want to do, but without th leap motion & the bike.

Is there any example for make this kind of snapping? or do you have any idea for snapping via scripting?

Here is and example script. To make it work you need to pair each part with game object. It may an empty game object. When you get close to that part (as viewed from a perspective camera), it will change color. To figure out close, the code projects the 3D position of the part and the partner game object onto a viewport and uses Viewport coordinates to do the calculation. If you drop the part while it is close, it moves and rotates into position as defined by its ‘partner’ object. Note that the color change depends on have a shader that supports material.color. Also it there is no drag and drop here and therefore must be done in a separate script.

#pragma strict

var partnerName = "Hub";
var closeVPDist = 0.05;
var moveSpeed = 40.0;
var rotateSpeed = 90.0;

var closeColor = Color(1,0,0);

private var dist = Mathf.Infinity;
private var normalColor : Color;
private var partnerGO : GameObject;

function Start() {
    normalColor = renderer.material.color;
    partnerGO = GameObject.Find(partnerName);

function OnMouseDrag() {
	var partnerPos = Camera.main.WorldToViewportPoint(partnerGO.transform.position);
	var myPos = Camera.main.WorldToViewportPoint(transform.position);
	dist = Vector2.Distance(partnerPos, myPos);
	renderer.material.color = (dist < closeVPDist) ? closeColor : normalColor;

function OnMouseUp() {
	if (dist < closeVPDist) {
		transform.parent = partnerGO.transform;

function InstallPart() {
	while (transform.localPosition != || transform.localRotation != Quaternion.identity) {
		transform.localPosition = Vector3.MoveTowards(transform.localPosition,, Time.deltaTime * moveSpeed);
		transform.localRotation = Quaternion.RotateTowards(transform.localRotation, Quaternion.identity, Time.deltaTime * rotateSpeed);

could you translate it into c# please?