UE的 HUD 类中的必备方法和属性

在屏幕上绘制的方法

1. DrawText()

DrawText() 方法允许开发者在屏幕上渲染文本。参数包括文本内容、位置、颜色、字体、缩放等。

void DrawText(
    const FString& Text, 
    const FLinearColor& TextColor, 
    float ScreenX, 
    float ScreenY, 
    UFont* Font, 
    float Scale = 1.0f, 
    bool bScalePosition = true, 
    bool bClipText = true, 
    FLinearColor DrawColor = FLinearColor::White, 
    float Kerning = 0.0f, 
    ETextDrawType DrawType = ETextDrawType::Shadow);

2. DrawRect()

用于绘制矩形形状的DrawRect() 方法。对于创建背景或边框非常有用。

void DrawRect(
    FLinearColor RectColor, 
    float ScreenX, 
    float ScreenY, 
    float ScreenW, 
    float ScreenH);

3. DrawTexture()

展示纹理在屏幕上的DrawTexture() 方法。参数包括纹理、位置、大小以及其他附加设置。

 
  
void DrawTexture(
    UTexture* Texture, 
    float ScreenX, 
    float ScreenY, 
    float ScreenW, 
    float ScreenH, 
    float Scale = 1.0f, 
    bool bScalePosition = true, 
    FLinearColor DrawColor = FLinearColor::White, 
    EBlendMode BlendMode = BLEND_Translucent, 
    float Rotation = 0.0f, 
    FVector2D RotPivot = FVector2D(0.5f, 0.5f), 
    bool bScaleToFit = false);

增强HUD功能的属性

1. Canvas

Canvas 属性是UCanvas 类型,表示HUD的画布,为在屏幕上绘制提供了平台。

UPROPERTY() class UCanvas* Canvas;

2. bShowHUD

bShowHUD 布尔属性确定HUD是否可见。

UPROPERTY() bool bShowHUD;

3. bShowDebugInfo

bShowDebugInfo 属性控制屏幕上调试信息的可见性。

UPROPERTY() bool bShowDebugInfo;

4. HUDFont

HUDFont 属性定义了HUD中文本使用的字体。

UPROPERTY() UFont* HUDFont;

你可能感兴趣的:(UC++,UC++,虚幻)