UE4 显示帧率的几种姿势「建议收藏」

在使用UE4Editor或者UE4Game时,有时候需要查看帧率,以及每帧耗时情况。在Editor中显示:键盘上按下~可以看到有个输入框出现:在输入框输入statfps或者statunit,出现帧率或者耗时:在Game中显示(1):启动Game.exe后,键盘按下~出现输入框,输入框中输入statfps或者statunit,回车:在

大家好,又见面了,我是你们的朋友全栈君。

欢迎关注公众号可以查看更多完整文章

UE4 显示帧率的几种姿势「建议收藏」

在使用UE4 Editor或者UE4 Game时,有时候需要查看帧率,以及每帧耗时情况。

在Editor中显示:

  • 键盘上 按下 ~
  • 可以看到有个输入框出现:
  • UE4 显示帧率的几种姿势「建议收藏」
  • 在输入框输入 stat fps或者stat unit,出现帧率或者耗时:
  • UE4 显示帧率的几种姿势「建议收藏」
也可以在偏好设置中设置:
UE4 显示帧率的几种姿势「建议收藏」
设置后显示在:
UE4 显示帧率的几种姿势「建议收藏」
还可以在视口中直接下拉选择显示与否:
UE4 显示帧率的几种姿势「建议收藏」
在Game中显示(1):
  • 启动Game.exe后,键盘按下 ~
  • 出现输入框,输入框中输入 stat fps或者stat unit,回车:UE4 显示帧率的几种姿势「建议收藏」
在Game中显示(2):
  • 在编辑器中,打开关卡蓝图编辑:
  • UE4 显示帧率的几种姿势「建议收藏」
  • 右键添加节点:
  • UE4 显示帧率的几种姿势「建议收藏」
  • 编辑Command:
  • UE4 显示帧率的几种姿势「建议收藏」
  • 启动Game.exe,查看效果:
  • UE4 显示帧率的几种姿势「建议收藏」
当然上面的方法是在Editor中实现,还可以直接在代码中实现:
1.调用UKismetSystemLibrary::ExecuteConsoleCommand:
/**
	 * Executes a console command, optionally on a specific controller
	 * 
	 * @param	Command			Command to send to the console
	 * @param	SpecificPlayer	If specified, the console command will be routed through the specified player
	 */
	UFUNCTION(BlueprintCallable, Category="Development",meta=(WorldContext="WorldContextObject"))
	static void ExecuteConsoleCommand(UObject* WorldContextObject, const FString& Command, class APlayerController* SpecificPlayer = NULL );
其本质上是调用的APlayerControllor的接口:
void UKismetSystemLibrary::ExecuteConsoleCommand(UObject* WorldContextObject, const FString& Command, APlayerController* Player)
{
	// First, try routing through the primary player
	APlayerController* TargetPC = Player ? Player : UGameplayStatics::GetPlayerController(WorldContextObject, 0);
	if( TargetPC )
	{
		TargetPC->ConsoleCommand(Command, true);
	}
}

2.还可以自己实现上述功能,直接调用APlayerControllor的接口:

UGameEngine *GameEngine = GEngine ? Cast<UGameEngine>(GEngine) : nullptr;
	UWorld* World = GameEngine ? GameEngine->GetGameWorld() : nullptr;
	//ULevel *Level = World ? World->PersistentLevel : nullptr;
	if (World)
	{
		APlayerController *Controller = World->GetFirstPlayerController();
		if (Controller)
		{
			Controller->ConsoleCommand(FString(command), false);
		}
	}

本文地址:
UE4 显示帧率的几种姿势_GreenArrowMan-CSDN博客-CSDN博客

交流qq:1245178753

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/129635.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)
blank

相关推荐

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号