UE4 常用打印调试信息方法

蓝图的Print String

这篇文章写得非常详细了:UE4蓝图API翻译【节点】— Print String

任意类型拖动到PrintString节点里可以直接生成toString方法,非常方便。
可以直接生成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 方法

检测碰撞位置,参考这篇文章: 虚幻引擎中的日志系统

如有侵权,请联系作者删除。带来不便,尽请谅解。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值