UI - Best method for Scene UI elements


I would like to know what the best method is in order to place Scene UI elements over the top of scene objects.

For example, I have a building that has a health script attached to it. When ‘_onFocus’ is true on this building, I would like to show a UI Health Bar that sits above the building, as if it appears in the scene.

Originally, I would just place a 3D plane/quad within the actual scene, and have that dynamically scale with the health percentage.

But I would like to take advantage to Unity’s builtin UI system. I have the Canvas with ‘World Space’ render mode, but how would I place a 2D UI element in Rect position with relation to my building in 3D space? Or am I going about this wrong way?


you can just child the canvas (World Space) containing the health bar to the respective GameObject and enter values for the RectTransform until it is in the right position relative to the Object. Additionally add a script to the canvas with has transform.LookAt(Camera.main.transform);in the Update() Loop.