You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Orange, FString::Printf(TEXT("My Location is: %s"), *GetActorLocation().ToString()));
52
+
```
53
+
54
+
下面是完整的 C++ 文件(使用宏定义可以简化打印调试信息的步骤)
55
+
56
+
<details>
57
+
<summary><b>AddBillboardComp.cpp</b> </summary>
58
+
59
+
```cpp
60
+
// Copyright (c) 2025 OpenHUTB at the Human University of Technology and Business (HUTB). This work is licensed under the terms of the MIT license. For a copy, see <https://opensource.org/licenses/MIT>.
61
+
62
+
#define print(text) if (GEngine) GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, text)
63
+
#define printFString(text, fstring) if (GEngine) GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Magenta, FString::Printf(TEXT(text), fstring))
64
+
65
+
#include "Tutorial/ConsoleLog.h"
66
+
67
+
// Sets default values
68
+
AConsoleLog::AConsoleLog()
69
+
{
70
+
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
71
+
PrimaryActorTick.bCanEverTick = true;
72
+
73
+
}
74
+
75
+
// Called when the game starts or when spawned
76
+
void AConsoleLog::BeginPlay()
77
+
{
78
+
Super::BeginPlay();
79
+
// 标注的方式:输出到控制台
80
+
UE_LOG(LogTemp, Warning, TEXT("I just started running"));
// Copyright (c) 2025 OpenHUTB at the Human University of Technology and Business (HUTB). This work is licensed under the terms of the MIT license. For a copy, see <https://opensource.org/licenses/MIT>.
2
+
3
+
#defineprint(text) if (GEngine) GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, text)
4
+
#defineprintFString(text, fstring) if (GEngine) GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Magenta, FString::Printf(TEXT(text), fstring))
5
+
6
+
#include"Tutorial/ConsoleLog.h"
7
+
8
+
// Sets default values
9
+
AConsoleLog::AConsoleLog()
10
+
{
11
+
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
12
+
PrimaryActorTick.bCanEverTick = true;
13
+
14
+
}
15
+
16
+
// Called when the game starts or when spawned
17
+
voidAConsoleLog::BeginPlay()
18
+
{
19
+
Super::BeginPlay();
20
+
// 标注的方式:输出到控制台
21
+
UE_LOG(LogTemp, Warning, TEXT("I just started running"));
0 commit comments