You don't need more than one UIRoot. What are you trying to do? To display something above the character's head, make it a regular widget, a part of the UI hierarchy, and make it anchored to a 3D object. Why are you trying to make it a part of the game world?
I need to display a 2d widget above an Unity sprite, something similar to a health bar. I need it to be "bundled" together with the game object because not making it that way would cause a lot of in game systems to feel "dirty" and require a lot of additional work to ensure everything from dynamic loading and unloading, instantiating, object painting etc, works.
"Even if you did make it a part of the game world, you don't need a UIRoot, and you don't need to make it "follow" anything. Simply making it a child of the 3D object will make it "follow" it."
Yes. Transform does "follow" the object but everything else, including the widget appearance, does not. Moving the the widget doesn't seem to move the appearance of the widget until a certain threshold is passed then it snaps to a position 800 px away. All in all a very strange behaviour.
See a screenshot in the attachment to see what I mean.
The widget appears in the scene view in one position but appears in game view in another (or it isn't in the game view at all). Note, the problems occur only if I move the widget outside of UIRoot as a parent of my game object. The widget does not have anchoring enabled.
If I just move it out of UIRoot so it doesn't have a parent it looks and behaves as it should. However, I can't use it like that because of previously mentioned problems.
To sum up what the widget needs to do:
- be a child/sibling of a game object that exists outside the UIRoot
- "follow" its target in x and y axis like a hud health bar
I don't need a bunch of advanced stuff and polish. I need just those two things.
Is it doable? How?