generated from pancake-llc/package
-
Notifications
You must be signed in to change notification settings - Fork 17
Optimize Health Bar
Aprius edited this page Oct 23, 2024
·
9 revisions
Optimized health bar rendering with a single draw command, useful for Roguelike games where there are many units on screen at the same time, and does not require too much customization in terms of healthbar display
It will draw the entire health bar with just 1 draw call
1, Create Canvas and set render mode is Screen Space - Overlay
2, Create a GameObject in the newly created canvas then add component UIHeathBarManager
- Camera : Camera render canvas contains healthBars
- Height : Adjust the height of the health bar
- Border : Adjust the thickness of the border surrounding the health bar
- Background : Adjust the background color of the health bar
Note that you need to set the pivot of the **UIHeathBarManager ** to the origin (0, 0)
3, Attach the HeathBar component to the object that needs to display the health bar.
- Width : Length of the health bar
- Opacity : Adjust the opacity
- Color : Color of the health bar
- Offset : Adjust the position offset
4, Setup the value for the health bar by calling the Initialize function of HealthBar