UEngine::AddOnScreenDebugMessage

Add a [FString](API\Runtime\Core\Containers\FString) to the On-screen debug message system.

Windows
MacOS
Linux

References

Module

Engine

Header

/Engine/Source/Runtime/Engine/Classes/Engine/Engine.h

Include

#include "Engine/Engine.h"

Source

/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp

Syntax

void AddOnScreenDebugMessage
(
    uint64 Key,
    float TimeToDisplay,
    FColor DisplayColor,
    const FString & DebugMessage,
    bool bNewerOnTop,
    const FVector2D & TextScale
)

Remarks

Add a FString to the On-screen debug message system. bNewerOnTop only works with Key == INDEX_NONE

This function will add a debug message to the onscreen message list. It will be displayed for FrameCount frames.

Parameters

Parameter

Description

Key

A unique key to prevent the same message from being added multiple times.

TimeToDisplay

How long to display the message, in seconds.

DisplayColor

The color to display the text in.

DebugMessage

The message to display.

Example Code

HelloWorldPrinter.cpp at line 14:

void AHelloWorldPrinter::Tick(float DeltaTime)  
{  
    Super::Tick(DeltaTime); //Call parent class Tick  

    static const FString ScrollingMessage(TEXT("Hello World: "));  

    if (GEngine)  
    {  
        const int32 AlwaysAddKey = -1; // Passing -1 means that we will not try and overwrite an   
                                       // existing message, just add a new one  
        GEngine->AddOnScreenDebugMessage(AlwaysAddKey, 0.5f, FColor::Yellow, ScrollingMessage + FString::FromInt(MyNumber));  

        const int32 MyNumberKey = 0; // Not passing -1 so each time through we will update the existing message instead  
                                     // of making a new one  
        GEngine->AddOnScreenDebugMessage(MyNumberKey, 5.f, FColor::Yellow, FString::FromInt(MyNumber));  

        ++MyNumber; // Increase MyNumber so we can see it change on screen  
    }  
}
Select Skin
Light
Dark

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback