Search code examples
c#unity-game-engineuser-interfacegame-development

How to align a UI element to its left position in Unity


filled health bar

I am trying to add a health bar to my game. It looks like this in hierarchy:

HealthBar

Red (The red bar behind)
Green (The green bar at the front)
Text (The number at the left)

When the bar is filled, it looks normal as the image above. But when I decrease the width of the green bar from the Rect Transform component, green bar centered it looks like this. The green bar's level decreases from both left and right.

How can I make it stay at left, and only decrease from right?


Solution

  • Please check out Video you'll get an idea of aligning Helthbar in Unity