Update #2: I found the issue. Took some debug but my main camera was not culling out the UI and therefore returning as the UI camera. Thus the poor offset.
Ok, I'm stumped.
I have:
A 3D Camera for my main camera that can be dragged around.
A UIRoot(2D) with a camera for the UI. UIRoot is located off to the side at (0,0,200)
I have a panel called "PANEL_DYNAMIC" that I parent all my dynamic UI elements to, mostly progress bars. Panel is a child of an object that has an anchor anchoring to the top left. All other position transforms are (0,0,0) and scales are (1,1,1)
I have a UIBarPrefab that is a prefab that has a UIFollowTarget script on it and a child with a label and another child with a progressbar.
This is my code for creating a bar inside the object I want it to follow:
void CreateBarObject()
{
GameObject pnl = GameObject.Find ("PANEL_DYNAMIC");
barObject = NGUITools.AddChild( pnl, UIBarPrefab );
barObject.GetComponent<UIFollowTarget>().target = transform;
}
The bar isn't showing up in the right position.
When I look at the update function for UIFollowTarget the barObject position calculates to (10.5,0.0, -1.5) but it's localPosition ends up being (4544.5, -378.8, 0). I'm not sure why. That's way off screen.
Update: No matter how I move around the object on the screen the position/locationposition doesn't change.
I verified the UIFollowTarget script is on the progress bar that gets created but it just doesn't follow the target.
What am I doing wrong? I've combed through as much documentation as I could find.