虚幻引擎可视记录器(The Visual Logger of Unreal Engine)

官方文档:
VisualLogger
可以切换语言到中文。

参考视频:
The Visual Logger: For All Your Gameplay Needs!

最近使用C++开发UE工程时,发现自己的debug手段单一。没错,就是UE_LOG宏,而且还用得很浅,自定义Category都没怎么用过。在查看UE的Path Follow代码时,发现UE_VLOG和Visual Logger,算是开了眼界了。通过使用它们,你可以非常直观地在UE Editor里看到寻路的信息。

附:
Logs,Printing Messages To Yourself During Runtime

Visual Logger打开方式
1、Windows > Developer Tools > Visual Logger
2、控制台中输入VisLog

我们主要做这三件事来帮助开发:

  • Taking Actor Snapshots
  • Loging Messages
  • Drawing Debug Shapes

1. Taking Actor Snapshots

需要注意的是ENABLE_VISUAL_LOG的使用。只有这个宏被定义了,我们才能通过重载virtual void GrabDebugSnapshot(FVisualLogEntry* Snapshot) const override;函数来添加actor snapshot。这个函数在IVisualLoggerDebugSnapshotInterface中声明。

#if ENABLE_VISUAL_LOG
    // Appends information about this actor to the visual logger.
    virtual void GrabDebugSnapshot(FVisualLogEntry* Snapshot) const override;
#endif

--------------------------------------------------------------------------------
#if ENABLE_VISUAL_LOG
void AGDCCharacter::GrabDebugSnapshot(FVisualLogEntry* Snapshot) const
{
    Super::GrabDebugSnapshot(Snapshot);
    const int32 CatIndex = Snapshot->Status.AddZeroed();
    FVisualLogStatusCategory& PlaceableCategory = Snapshot->Status[CatIndex];
    PlaceableCategory.Category = TEXT("GDC Sample");
    PlaceableCategory.Add(TEXT("Projectile Class"), ProjectileClass != nullptr ? ProjectileClass->GetName() : TEXT("None"));
}
#endif

2. Loging Messages & 3. Drawing Debug Shapes

记得引用头文件

//必须要的,实用的UE_VLOG宏都在这里面,使用UE_VLOG可以不用考虑ENABLE_VISUAL_LOG宏
#include "VisualLogger/VisualLogger.h"

//可能还要
#include "VisualLogger/VisualLoggerTypes.h"
......

当然我们还可检查Visual Logger是否在运行:

FVisualLogger& Vlog = FVisualLogger::Get();
if(Vlog.IsRecording())
{
}

你可能感兴趣的:(虚幻引擎可视记录器(The Visual Logger of Unreal Engine))