Skip to content

HUD System Overview

Indigocoder1 edited this page Oct 23, 2024 · 3 revisions

HUD System Components

There are 2 main components of the Sub Library HUD System

  1. The ModdedSubHudManager
  2. The IUIElement interface

Modded Sub HUD Manager

Sub Library has a component named the ModdedSubHudManager, which controls the pilot HUD. It handles blending the alpha of the HUD between 0 and 1 when the player is not piloting and piloting respectively.

It also handles the UI Elements, such as the Health Bar, Depth meter, Power meter, and others.

UI Elements

The IUIElement interface is in charge of coordinating updates between all UI elements through the HUD manager.

There are multiple UI Elements out of the box for you to use, which include

  • Depth UI Manager
  • Engine UI Manager
  • Health UI Manager
  • Noise UI Manager
  • Power UI Manager
  • Speed UI Manager
  • Warning UI Manager

These systems are easily expandable though, and all you have to do to make a new UI Element is to make a class inheriting from MonoBehavior (To attach to a GameObject) and IUIElement.
Here's an example class you could make that logs to the in-game popup text:

public class MyCoolUIElement : MonoBehavior, IUIElement
{
    /// <summary>
    /// Called every frame when the sub is alive and in LOD distance
    /// </summary>
    public void UpdateUI()
    {
        ErrorMessage.AddMessage("Updating UI!");
    }

    /// <summary>
    /// Called when the sub is destroyed
    /// </summary>
    public void OnSubDestroyed()
    {
        ErrorMessage.AddMessage("Sub destroyed!");
    }
}