Skip to main content

Balloon Components

Overview

The Balloon Component can display the required content, for example, the character's Health Point or Name, at any position of the character or object, as shown in the picture below:

Creating Balloon Components

Creating Characters

To create a Balloon Component, a character is needed first. Drag a character (SK_Human_new.actor) from the Resource Preview window into the scene.

image-20230721110929294

Adding Balloon Components

Select the character you just created (SK_Human_new.actor) in the Hierarchy panel, then click Add Component -> Balloon Component in the Inspector panel to add a Balloon Component.

image-20230721111302152

Editing Balloon Components

Select the Balloon Component you just added (LBalloon), then select any UI file in the Project panel (here we select the health point UI file form_blood-bar.ui) and drag it into the drop-down box of File under the Balloon category. Then the health point UI will be displayed over the character's head (by default). The properties of the balloon component can be modified in Balloon under Proxy Object.

image-20230721124959433

Properties and Methods of Balloon Components

Properties

PropertyDescription
Bind XThe offset (position) of the bound X-axis in 3D space
Bind YThe offset (height) of the bound Y-axis in 3D space
Bind ZThe offset (distance) of the bound Z-axis in 3D space
Offset LeftDistance offset from left to right starting with Bind X
Offset TopDistance offset from left to right starting with Bind Y
Near DistanceThe nearest display distance from the current camera to the component.
Far DistanceThe farthest display distance from the current camera to the component.
Use UpOrientation mode
If checked: Orientation offset away from the world center
If unchecked: Orthogonal relative position (over the character's head by default, e.g. the health point)
Use Depth ScaleThe GUI control scales synchronously with the bound object

Methods

MethodDescription
LoadFormThis method needs to be passed in a UI file
AddControlThis method needs to add a custom control, no need to pass in the UI file

Note: LoadForm passes in the UI file while AddControl passes in the custom control. Only one of the UI file and the custom control will take effect. You can choose to call LoadForm method or AddControl method as needed.

LoadForm

-- DECLARE_METHOD_1:LoadForm 
-- Load the UI file, which is added over the character's head by default
LBalloonComponent* m_pBalloonComponent = NewObject<LBalloonComponent>(this, FXTEXT("BalloonComponent"));
m_pBalloonComponent->LoadForm("skin\\blood_bar\\form_blood_bar.ui")

AddControl

-- DECLARE_METHOD_1:AddControl 
-- Add the custom GUI control,which is added over the character's head by default
IEntity* pGui = (IEntity*)CHelper::GetGlobalEntity("gui");
PERSISTID button = pGui->Create("Button")
IEntity* pButton = g_pCore->GetEntity(button);
CHelper::SetPropertyInt(pButton, "Width", 240);
CHelper::SetPropertyString(pButton, "DrawMode", "FitWindow");
CHelper::SetPropertyString(pButton, "BackImage", "skin_res\\button\\btn_push.png");
LBalloonComponent* m_pBalloonComponent = NewObject<LBalloonComponent>(this, FXTEXT("BalloonComponent"));
m_pBalloonComponent->AddControl(button)