Turning a 2d game into 2.5d game programatically. (Script included)

I made a game with a bunch of levels using simple square sprites. All of them have a rotation of 0,0,0, the scale of each square is changed to make the square horizontal or vertical. Now I want to make the levels 2.5d (I made 8 simple levels like the one below to see what gameplay would be like). I don’t want to have to manually tweak every shape to get them to fit together correctly, so I made a script to find all the sprites in each level and add a 3d box over the top of it. It works pretty well actually. The issue I have is with the corners. Any ideas on how to get them to blend together nicely like legos without putting any manual labor in? (Last game I made I hid all the corners with spheres, which looked pretty cool, but i’d rather avoid doing that.) Below is the code i’ve got to make the left image look like the right image when you run the script.

public class ThreeDMaker : MonoBehaviour {

    List<Transform> transformsWithSprites;
    public GameObject cubePrefab;

    // Use this for initialization
    void Start () {
        transformsWithSprites = new List<Transform> ();
        Make3D ();
    }

    public void Make3D() {
        GameObject level = GameObject.FindGameObjectWithTag ("Level");
        FindAllSpriteObjects (level.transform);
        foreach (Transform t in transformsWithSprites) {
            GameObject cube = (GameObject)Instantiate (cubePrefab, t);
            Transform cubeParent = cube.transform.parent;
            Vector3 cubeParentScale = cubeParent.localScale;
            cube.transform.rotation = Quaternion.Euler (-20/cubeParentScale.y,-10/cubeParentScale.x,0);
        }

    }

    public void FindAllSpriteObjects(Transform trans) {
        if (trans.childCount > 0) {
            for (int i = 0; i < trans.childCount; i++) {
                FindAllSpriteObjects (trans.GetChild (i));
            }
        }
        SpriteRenderer sr = trans.GetComponent<SpriteRenderer> ();
        if (sr != null) {
            transformsWithSprites.Add (trans);
        }

    }

Edit: works for rotated cubes by changing the Z component of line 19 to cubeParent.transform.eulerAngles.z