蓝图的Print String
这篇文章写得非常详细了:UE4蓝图API翻译【节点】— Print String
任意类型拖动到PrintString节点里可以直接生成toString方法,非常方便。
C++的 AddOnScreenDebugMessage 方法
源代码:
/**
* This function will add a debug message to the onscreen message list.
* It will be displayed for FrameCount frames.
*
* @param Key A unique key to prevent the same message from being added multiple times.
* 用来防止相同信息被显示多次:当Key为0时,相同的信息只在界面上显示一次;当Key为-1时,相同信息会按照程序执行依次显示。
* @param TimeToDisplay How long to display the message, in seconds.
* 信息显示时间
* @param DisplayColor The color to display the text in.
* 信息颜色
* @param DebugMessage The message to display.
* 打印的消息
* @param bNewerOnTop 用来确定一系列信息显示的位置:当bNewerOnTop=true时,最新的信息永远显示在顶部;当bNewerOnTop=false时,最新的信息显示在底部,缺省时默认为true。
* @param TextScale
*/
void UEngine::AddOnScreenDebugMessage(uint64 Key, float TimeToDisplay, FColor DisplayColor, const FString& DebugMessage, bool bNewerOnTop, const FVector2D& TextScale)
一般使用方法:
if (GEngine)
{
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, FString::Printf(TEXT("Print Message this is %f"), 2.3f));
}
UE_LOG
UE_LOG(日志种类Category, 日志级别Verbosity, 日志内容Content)
一般使用方法:
UE_LOG(LogTemp, Warning, TEXT("Line Hit is %f"), 3.02f);
第二个参数有:
Log 显示白色文字
Warning 显示黄色文字
Error 显示红色文字
DrawDebugString 方法
检测碰撞位置,参考这篇文章: 虚幻引擎中的日志系统
如有侵权,请联系作者删除。带来不便,尽请谅解。