unity change object parent code example
Example 1: transform object according to its parent unity
transform.localPosition = new Vector3(12.5f, 12.5f, 12.5f);
Example 2: set parent of gameobject unity
child.transform.SetParent(newParent);
transform.localPosition = new Vector3(12.5f, 12.5f, 12.5f);
child.transform.SetParent(newParent);