UIHealthBar - jimdroberts/FishMMO GitHub Wiki

Description

UIHealthBar is a UI component in the FishMMO client that displays the player's health. It inherits all resource bar logic from UIResourceBar and is specialized for showing health values.


API Access

Inherits

  • UIResourceBar

Fields

  • (All fields are inherited from UIResourceBar)

Methods

  • (All methods are inherited from UIResourceBar)

Basic Usage

Setup

  1. Attach UIHealthBar to a UI GameObject in the Unity Editor.
  2. Assign the slider and resourceValue fields in the Inspector.
  3. Set the Template field to the health attribute template.

Example

// Example: Using UIHealthBar in a scene
UIHealthBar healthBar = GetComponent<UIHealthBar>();
healthBar.slider = ...; // Assign Slider
healthBar.resourceValue = ...; // Assign TMP_Text
healthBar.Template = healthTemplate; // Assign CharacterAttributeTemplate for health

Best Practices

  • Use UIHealthBar for health display and inherit from UIResourceBar for other resource bars.
  • Always assign all required fields in the Inspector to avoid null references.
  • Ensure the correct attribute template is set for health.
⚠️ **GitHub.com Fallback** ⚠️