[c#] screen to local/object coordinates, best method

I have a number of objects, using playing cards for test, on top of each other like this: 1614975--98375--$Skärmavbild 2014-05-04 kl. 00.47.54.png

The objects are perfectly lined out and then i click on Heart Queen (HQ) and get the following: 1614975--98376--$after.png

When i click on HQ i do make the HQ parent and the other yellow is child’s as well as increase their sort order to get them on top. Here is the code i use for this:

print ("Here we go - " + MainScript.selectedGameObjectList.Count);

		firstRound = true;

		// Allocate all selected objects to the container
		foreach(GameObject aGameObject in MainScript.selectedGameObjectList) {

			if(firstRound) {
				// At the first round do not add child as the first object is parent

				theFirstGO = aGameObject;

//				theFirstGO.transform.renderer.sortingOrder = 100;

				firstRound = false;
			}
			else {
				// Add to parent
				print (aGameObject.name + " / " + aGameObject.transform.position);

				aGameObject.transform.parent = theFirstGO.transform;
				aGameObject.collider2D.enabled = false;

			}
		}

		// Make sure the selected container, with all it's objects, get's on top

		theMainScript = new MainScript(); // Set up access to MainScript
		GameObject dummyGO;

		int lengthOfList = MainScript.selectedGameObjectList.Count;

		for(int zz = 0; zz < MainScript.selectedGameObjectList.Count; zz++) {
			MainScript.selectedGameObjectList[zz].transform.renderer.sortingOrder = 100; //transform.renderer.sortingOrder;
		}

However, my challenge is how to, except for the selected object (HQ) which get’s on top, keep the position for the child’s the parent after selection? I know there is some functions for some type of conversion like world to local etc. but have not been able to figure out how to do this?

Worst case i guess this needs to be done manually for each selected object, which i tried but not really got it perfect.

Not that it matters but in Objective-C/SpriteKit I would manually do it this way:

//////SAVE THE REALATIVE POSITION BETWEEN THE NODE ON SCREEN AND IN THE CONTAINER//////
 [_relativePositionDifferenceArray addObject:aNode.name];
 [_relativePositionDifferenceArray addObject:[NSNumber valueWithCGPoint:CGPointMake(aNode.position.x - _containerNode.position.x, aNode.position.y - _containerNode.position.y)]];
 [_relativePositionDifferenceArray addObject:[NSNumber numberWithFloat:aNode.zRotation]];

If you want to only move the parent object, you could try this and adjust/optimize it for your needs.

public Transform[] childs;
public bool onlyParent;
void Update()
{
     if (Input.GetKey(KeyCode.W))
     {
          transform.Translate(Vector3.forward * Time.deltaTime*5);
          if (onlyParent)
          {
               foreach (Transform c in childs)
               {
                    // move it into the opposite direction 'back' or  ' - Vector3.forward'
                    c.Translate(Vector3.back * Time.deltaTime*5);
               }
          }
     }

     // press C to assign all childs to the array
     if (Input.GetKeyDown(KeyCode.C))
     {
            childs = new Transform[transform.childCount];
            for (int i = 0; i < childs.Length; i++)
          {
                childs[i] = transform.GetChild(i);
          }
     }
}