How can I rotate a GameObject without rotating the GUI?

Well, heres my problem. I am creating a 2D game where I have to instantiate 30 different pieces where I have to set a piece and accept it in its position. Positioning includes rotation, however, I currently have the GUI set as a child of a gameobject. I can get the buttons of the canvas to not rotate using the following:

#pragma strict
function Update () {

	transform.rotation = Quaternion.identity;
}

However the location of the canvas still changes as if it is rotating, as depicted in the images below.

76951-no-rotate.png

76952-rotate-90-ccw.png

I want this to work the most efficiently as possible. I want to find a way to make it so it isn’t rotating. The only reason I did it this way was because it needs to be able to follow all 30 pieces after they were instantiated in runtime. I figured the easiest way was to add the canvas to the prefabs and then SetActive = false; until they were ready to be used.

Ideally I would like it to be separate where 1 canvas and buttons control them all as they are instantiated. However, if this is difficult/impossible, then I would like to figure out a way to prevent the canvas from moving.

Also it is set to world space because the other options are not adjustable to what I need, if there is anything else that might be useful in this, any help is good help. Thank you in advance.

You will have to rotate the children of this object in the opposite direction.

for(int i = 0; i < transform.childCount; i++){
transform.GetChild(i).rotation = transform.rotation*-1;
}

For those experiencing the same problem, I had to separate the canvas from the parent object and link the GameObject to a variable in what was the parent object script, using the inspector in Unity. I was then able to tell it where to position itself using the variable in the script.

#pragma strict

// Variable that holds the panel GameObject

public var guiPanel : GameObject;

function Update () {

// Position the Panel -2.5 below the game piece

	guiPanel.transform.position = new Vector3(transform.position.x, transform.position.y - 2.5, 0);
}

This does work, and I can use the same menu for all the game pieces instead of 1 for 1. This also prevents having unruly coding within the scripts trying to reverse rotation.