I've written a prototype of something like this. I created some resources that looked like this:
So basically this "ShipPart" object has pre-defined snap points. These four colliders will help with determining if you are attempting to snap an object into place or not.
Next I created a ShipPart class, that contains some things such as:
ShipPart Left, Right, Top, Bottom;
//The ship core it is attached to
//The coordinates in references to the ship core
int X ;
int Y ;
It also contains functions and properties to help with the drag and drop, and checking the state of the neighboring ShipParts.
An important function is the Attach() function, which will connect this ShipPart to your Ship.
public void Attach(Ship ship, int x, int y)
GetComponent<Rigidbody2D> ().isKinematic = true;
Ship = ship;
X = x;
Y = y;
transform.parent = Ship.transform;
transform.position = Vector2.zero;
transform.localPosition = new Vector2(x, -y);
Then finally, the Ship class, keeps track of your Core piece, all of the attached parts, all of the ships data is managed here. You can raycast for ship parts in this class. Check the part that you are currently dragging to see if any of the colliders are colliding with other parts.
If there is a collision, check if the rotation is within your specified threshold and then snap it into place.
This is actually a lot more complicated to explain than I thought it would be. Let me know if you have questions and I will elaborate on whatever you need more help with.