Language:
Discover
By Skill Level
By Category

UEngine::AddOnScreenDebugMessage

Choose your OS:

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

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  
    }  
}

References

Module

Engine

Header

Runtime/Engine/Classes/Engine/Engine.h