UFUNCTION(Exec)
在UFUNCTION元标记中添加Exec
指示符,可以在Console中执行函数。
但它也有一些限制,文档中说的含糊不清:
Exec
: The function can be executed from the in-game console. Exec commands only function when declared within certain Classes.
但具体是在哪些类中有效果却没说。调试后发现:
- UWorld
- APlayerController
- APawn
- AHUD
- AGameMode
- UCheatManager
- AGameState
- APlayerCameraManager
具体代码为:Runtime/Engine/Private/Player.cpp#L94
bool UPlayer::Exec( UWorld* InWorld, const TCHAR* Cmd,FOutputDevice& Ar)
调用栈: