虚幻 · 新知

Hello,Unreal.
2023-06-19 lipengzha

adb执行console命令

adb shell "am broadcast -a android.intent.action.RUN -e cmd 'stat fps'"

引擎中的Device Log界面中对设备执行Console指令就是通过该命令的封装实现的,实现代码为:AndroidTargetDevice.inl#L102

2023-06-19 lipengzha

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.

但具体是在哪些类中有效果却没说。调试后发现:

  1. UWorld
  2. APlayerController
  3. APawn
  4. AHUD
  5. AGameMode
  6. UCheatManager
  7. AGameState
  8. APlayerCameraManager

具体代码为:Runtime/Engine/Private/Player.cpp#L94

bool UPlayer::Exec( UWorld* InWorld, const TCHAR* Cmd,FOutputDevice& Ar)

调用栈: