Skip to main content

BarUI

class SoftKitty.MasterHealthBarSystem.BarUI : WorldToScreenPosition

Description

BarUI is the runtime visual component used by both overhead bars and static bars. For floating overhead bars, the system creates and manages it automatically through HealthBarManager. For static HUD bars, you initialize it manually and optionally link it to an Entity.


Public Fields and Properties

  • bool StaticBar
    • Enable this when the prefab is used as a fixed UI bar, such as a player HUD bar.
  • RectTransform oteRoot
    • Parent transform for Over-time Effect icons on static bars.
  • int Health, int MaxHealth, int Shield, int MaxShield
    • Runtime values displayed by the bar.
  • bool ActiveCrack, bool ActiveInnerLine, bool ActiveOutline
    • Runtime visual toggles.
  • BarSetting myBarSetting
    • Resolves the current bar setting from BarUID.
  • BarStyle myStyle
    • Current bar style used by this instance.

Core Methods

void Init(HealthBar _bar, BarStyle _style, string _barUid, int _index = 0, Vector2 _size = default)

Initializes the bar instance.

  • _bar: owning HealthBar. Pass null for static bars.
  • _style: bar style type.
  • _barUid: bar preset UID from BarSettings.
  • _index: bar index. 0 is the main bar.
  • _size: optional explicit size override.

Notes:

  • Floating world-space bars are initialized automatically by the system.
  • Static HUD bars must call Init() manually.
  • If you use EntityManager with a static bar, also call LinkEntity(Entity _entity).
  • If you do not use EntityManager, manually set values through Health, MaxHealth, Shield, and MaxShield.

void LinkEntity(Entity _entity)

Links a static bar to an Entity when EntityManager integration is enabled. This method only applies to StaticBar == true.

void PopNumberText(string _uid, int _num)

Displays floating combat text from this bar. Use this for static bars. For floating overhead bars, call HealthBar.PopNumberText() instead.


Static Bar Example

public BarUI playerBar;

void Start()
{
playerBar.Init(null, BarStyle.HealthBall, "DemoPlayer");
}

Static Bar With EntityManager

public BarUI playerBar;
public Entity playerEntity;

void Start()
{
playerBar.Init(null, BarStyle.HealthBall, "DemoPlayer");
playerBar.LinkEntity(playerEntity);
}

Static Bar Popping Text

playerBar.PopNumberText("DamageText", 120);

Usage Notes

  • Use StaticBar for fixed screen-space UI bars.
  • Create and assign oteRoot if you want static bars to show Over-time Effect icons.
  • Create and assign damageRoot if you want static bars to show floating combat text.
  • In world-space mode, the system handles creation, pooling, and positioning automatically.