// create a new gameObject to add a UIPanel to. This object is needed
// because layering multiple UIWidgets in a GUI isn't allowed and in order
// for the UIPanel to contain the widgets, we need to attach it as the temp
// parent to where all the widgets (that we want to highlight) reside within it.
this.panelObj = new GameObject
(); this.panelObj.transform.parent = this.TutorialGameObject.transform.parent;
this.panelObj.transform.position = Vector3.zero;
this.panelObj.transform.rotation = Quaternion.identity;
// reparent the object to the new object
this.TutorialGameObject.transform.parent = this.panelObj.transform;
// we add a UIPanel to the object so it can actually be shown through
// the overlay, after re-positioning. This is needed because putting the
// obj in it's own panel re-orders the draw calls so it is actually
// drawn in front.
this.panel = this.panelObj.AddComponent<UIPanel>();
// tell each widget within the panel that the hierarchy has changed,
// and they need to recheck themselves.
foreach(UIWidget w in this.panel.GetComponentsInChildren<UIWidget>())
w.CheckParent();
// refresh the panel to update it's widgets
panel.Refresh();
// cache starting position and rotation (so we can move it back in Destroy()
oldObjectsPosition = this.TutorialGameObject.transform.position;
oldObjectsRotation = this.TutorialGameObject.transform.rotation;
// move object in front of the overlay so it can register clicks
Vector3 newPosition = TutorialGameObject.transform.position;
newPosition.z = this.overlayGameObj.transform.position.z;
newPosition.z += -.7f;
TutorialGameObject.transform.position = newPosition;