当前位置: 首页 > news >正文

UE5.4.3 录屏回放系统ReplaySystem蓝图版

这是ReplaySystem的蓝图使用方法版,以第三人称模版为例,需要几个必须步骤

项目config内DefaultEngine.ini的最后添加:

[/Script/Engine.GameEngine]
+NetDriverDefinitions=(DefName="DemoNetDriver",DriverClassName="/Script/Engine.DemoNetDriver",DriverClassNameFallback="/Script/Engine.DemoNetDriver")

项目的.build.cs用添加Josn模块

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "EnhancedInput","Json" });

创建MyGameInstance继承至GameInstance

MyGameInstance.h

// Fill out your copyright notice in the Description page of Project Settings.#pragma once#include "CoreMinimal.h"
#include "Engine/GameInstance.h"#include "NetworkReplayStreaming.h"
#include "Runtime/NetworkReplayStreaming/NullNetworkReplayStreaming/Public/NullNetworkReplayStreaming.h"
#include "Misc/NetworkVersion.h"#include "MyGameInstance.generated.h"USTRUCT(BlueprintType)
struct FS_ReplayInfo
{GENERATED_USTRUCT_BODY()UPROPERTY(BlueprintReadOnly)FString ReplayName;UPROPERTY(BlueprintReadOnly)FString FriendlyName;UPROPERTY(BlueprintReadOnly)FDateTime Timestamp;UPROPERTY(BlueprintReadOnly)int32 LengthInMS;UPROPERTY(BlueprintReadOnly)bool bIsValid;FS_ReplayInfo(){ReplayName = "Replay";FriendlyName = "Replay";Timestamp = FDateTime::MinValue();LengthInMS = 0;bIsValid = false;}FS_ReplayInfo(FString NewName, FString NewFriendlyName, FDateTime NewTimestamp, int32 NewLengthInMS){ReplayName = NewName;FriendlyName = NewFriendlyName;Timestamp = NewTimestamp;LengthInMS = NewLengthInMS;bIsValid = true;}
};UCLASS()
class REPLAYUE54_API UMyGameInstance : public UGameInstance
{GENERATED_BODY()public:UFUNCTION(BlueprintCallable, Category = "Replays")void StartRecordingReplayFromBP(FString ReplayName, FString FriendlyName);UFUNCTION(BlueprintCallable, Category = "Replays")void StopRecordingReplayFromBP();UFUNCTION(BlueprintCallable, Category = "Replays")void PlayReplayFromBP(FString ReplayName);UFUNCTION(BlueprintCallable, Category = "Replays")void FindReplays();UFUNCTION(BlueprintCallable, Category = "Replays")void RenameReplay(const FString& ReplayName, const FString& NewFriendlyReplayName);UFUNCTION(BlueprintCallable, Category = "Replays")void DeleteReplay(const FString& ReplayName);virtual void Init() override;TSharedPtr<INetworkReplayStreamer> EnumerateStreamsPtr;FEnumerateStreamsCallback OnEnumerateStreamsCompleteDelegate1;void OnEnumerateStreamsComplete1(const FEnumerateStreamsResult& Result);FDeleteFinishedStreamCallback OnDeleteFinishedStreamCompleteDelegate1;void OnDeleteFinishedStreamComplete1(const FDeleteFinishedStreamResult& Result);UFUNCTION(BlueprintImplementableEvent, Category = "Replays")void BP_OnFindReplaysComplete1(const TArray<FS_ReplayInfo>& AllReplaysm);	};

MyGmaeInstance.cpp

// Fill out your copyright notice in the Description page of Project Settings.#include "MyGameInstance.h"#include "Modules/ModuleManager.h"
#include "Runtime/Core/Public/HAL/FileManager.h"
#include "Runtime/Core/Public/Misc/FileHelper.h"void UMyGameInstance::Init()
{Super::Init();// create a ReplayStreamer for FindReplays() and DeleteReplay(..)EnumerateStreamsPtr = FNetworkReplayStreaming::Get().GetFactory().CreateReplayStreamer();// Link FindReplays() delegate to functionOnEnumerateStreamsCompleteDelegate1 = FEnumerateStreamsCallback::CreateUObject(this, &UMyGameInstance::OnEnumerateStreamsComplete1);// Link DeleteReplay() delegate to functionOnDeleteFinishedStreamCompleteDelegate1 = FDeleteFinishedStreamCallback::CreateUObject(this, &UMyGameInstance::OnDeleteFinishedStreamComplete1);
}
void UMyGameInstance::StartRecordingReplayFromBP(FString ReplayName, FString FriendlyName)
{StartRecordingReplay(ReplayName, FriendlyName);
}void UMyGameInstance::StopRecordingReplayFromBP()
{StopRecordingReplay();
}void UMyGameInstance::PlayReplayFromBP(FString ReplayName)
{PlayReplay(ReplayName);
}
void UMyGameInstance::FindReplays()
{if (EnumerateStreamsPtr.Get()){EnumerateStreamsPtr.Get()->EnumerateStreams(FNetworkReplayVersion(), int32(), FString(), TArray<FString>(), OnEnumerateStreamsCompleteDelegate1);}
}void UMyGameInstance::OnEnumerateStreamsComplete1(const FEnumerateStreamsResult& Result)
{TArray<FS_ReplayInfo> AllReplays;for (FNetworkReplayStreamInfo StreamInfo : Result.FoundStreams){void BP_OnFindReplaysComplete1(const TArray<FS_ReplayInfo> &AllReplaysm);if (!StreamInfo.bIsLive){AllReplays.Add(FS_ReplayInfo(StreamInfo.Name, StreamInfo.FriendlyName, StreamInfo.Timestamp, StreamInfo.LengthInMS));}}BP_OnFindReplaysComplete1(AllReplays);
}void UMyGameInstance::RenameReplay(const FString& ReplayName, const FString& NewFriendlyReplayName)
{// Get File InfoFNullReplayInfo Info;const FString DemoPath = FPaths::Combine(*FPaths::ProjectSavedDir(), TEXT("Demos/"));const FString StreamDirectory = FPaths::Combine(*DemoPath, *ReplayName);const FString StreamFullBaseFilename = FPaths::Combine(*StreamDirectory, *ReplayName);const FString InfoFilename = StreamFullBaseFilename + TEXT(".replayinfo");TUniquePtr<FArchive> InfoFileArchive(IFileManager::Get().CreateFileReader(*InfoFilename));if (InfoFileArchive.IsValid() && InfoFileArchive->TotalSize() != 0){FString JsonString;*InfoFileArchive << JsonString;Info.FromJson(JsonString);Info.bIsValid = true;InfoFileArchive->Close();}// Set FriendlyNameInfo.FriendlyName = NewFriendlyReplayName;// Write File InfoTUniquePtr<FArchive> ReplayInfoFileAr(IFileManager::Get().CreateFileWriter(*InfoFilename));if (ReplayInfoFileAr.IsValid()){FString JsonString = Info.ToJson();*ReplayInfoFileAr << JsonString;ReplayInfoFileAr->Close();}
}
void UMyGameInstance::DeleteReplay(const FString& ReplayName)
{if (EnumerateStreamsPtr.Get()){EnumerateStreamsPtr.Get()->DeleteFinishedStream(ReplayName, OnDeleteFinishedStreamCompleteDelegate1);}
}void UMyGameInstance::OnDeleteFinishedStreamComplete1(const FDeleteFinishedStreamResult& Result)
{FindReplays();
}

创建ReplayControllerplayer类继承至PlayerController类

ReplayControllerplayer.h
// Fill out your copyright notice in the Description page of Project Settings.#pragma once#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "ReplayControllerplayer.generated.h"/*** */
UCLASS()
class REPLAYUE54_API AReplayControllerplayer : public APlayerController
{GENERATED_BODY()public:/** we must set some Pause-Behavior values in the ctor */AReplayControllerplayer(const FObjectInitializer& ObjectInitializer);protected:/** for saving Anti-Aliasing and Motion-Blur settings during Pause State */int32 PreviousAASetting;int32 PreviousMBSetting;public:/** Set the Paused State of the Running Replay to bDoPause. Return new Pause State */UFUNCTION(BlueprintCallable, Category = "CurrentReplay")bool SetCurrentReplayPausedState(bool bDoPause);/** Gets the Max Number of Seconds that were recorded in the current Replay */UFUNCTION(BlueprintCallable, Category = "CurrentReplay")int32 GetCurrentReplayTotalTimeInSeconds() const;/** Gets the Second we are currently watching in the Replay */UFUNCTION(BlueprintCallable, Category = "CurrentReplay")int32 GetCurrentReplayCurrentTimeInSeconds() const;/** Jumps to the specified Second in the Replay we are watching */UFUNCTION(BlueprintCallable, Category = "CurrentReplay")void SetCurrentReplayTimeToSeconds(int32 Seconds);/** Changes the PlayRate of the Replay we are watching, enabling FastForward or SlowMotion */UFUNCTION(BlueprintCallable, Category = "CurrentReplay")void SetCurrentReplayPlayRate(float PlayRate = 1.f);
};

ReplayControllerplayer.cpp

// Fill out your copyright notice in the Description page of Project Settings.#include "ReplayControllerplayer.h"
#include "Engine/World.h"
#include "Engine/DemoNetDriver.h"AReplayControllerplayer::AReplayControllerplayer(const FObjectInitializer& ObjectInitializer)
{bShowMouseCursor = true;PrimaryActorTick.bTickEvenWhenPaused = true;bShouldPerformFullTickWhenPaused = true;
}bool AReplayControllerplayer::SetCurrentReplayPausedState(bool bDoPause)
{AWorldSettings* WorldSettings = GetWorldSettings();// Set MotionBlur off and Anti Aliasing to FXAA in order to bypass the pause-bug of bothstatic const auto CVarAA = IConsoleManager::Get().FindConsoleVariable(TEXT("r.DefaultFeature.AntiAliasing"));static const auto CVarMB = IConsoleManager::Get().FindConsoleVariable(TEXT("r.DefaultFeature.MotionBlur"));if (bDoPause){PreviousAASetting = CVarAA->GetInt();PreviousMBSetting = CVarMB->GetInt();// Set MotionBlur to OFF, Anti-Aliasing to FXAACVarAA->Set(1);CVarMB->Set(0);WorldSettings->SetPauserPlayerState(PlayerState);return true;}// Rest MotionBlur and AACVarAA->Set(PreviousAASetting);CVarMB->Set(PreviousMBSetting);WorldSettings->SetPauserPlayerState(NULL);return false;
}int32 AReplayControllerplayer::GetCurrentReplayTotalTimeInSeconds() const
{if (GetWorld()){if (UDemoNetDriver* DemoNetDriver = GetWorld()->GetDemoNetDriver()){return DemoNetDriver->GetDemoTotalTime();}}return 0;
}int32 AReplayControllerplayer::GetCurrentReplayCurrentTimeInSeconds() const
{if (GetWorld()){if (UDemoNetDriver* DemoNetDriver = GetWorld()->GetDemoNetDriver()){return DemoNetDriver->GetDemoCurrentTime();}}return 0;
}void AReplayControllerplayer::SetCurrentReplayTimeToSeconds(int32 Seconds)
{if (GetWorld()){if (UDemoNetDriver* DemoNetDriver = GetWorld()->GetDemoNetDriver()){DemoNetDriver->GotoTimeInSeconds(Seconds);}}
}void AReplayControllerplayer::SetCurrentReplayPlayRate(float PlayRate)
{if (GetWorld()){if (UDemoNetDriver* DemoNetDriver = GetWorld()->GetDemoNetDriver()){GetWorld()->GetWorldSettings()->DemoPlayTimeDilation = PlayRate;}}
}

创建MyGmaeInstance与ReplayController的BP蓝图类

UserInterface类:ReplayChild,ReplayMenu,ReplaySpectator

项目设置中

BP_MyGameInstance

 BP_ReplayController

 BP_ThirdPersonGameMode中的设置

 ReplayChild

ReplayMenu 

 

 

 ReplaySpectator

 

相关文章:

UE5.4.3 录屏回放系统ReplaySystem蓝图版

这是ReplaySystem的蓝图使用方法版&#xff0c;以第三人称模版为例&#xff0c;需要几个必须步骤 项目config内DefaultEngine.ini的最后添加&#xff1a; [/Script/Engine.GameEngine] NetDriverDefinitions(DefName"DemoNetDriver",DriverClassName"/Script/…...

ECCV 2024 | 融合跨模态先验与扩散模型,快手处理大模型让视频画面更清晰!

计算机视觉领域顶级会议 European Conference on Computer Vision&#xff08;ECCV 2024&#xff09;将于9月29日至10月4日在意大利米兰召开&#xff0c;快手音视频技术部联合清华大学所发表的题为《XPSR: Cross-modal Priors for Diffusion-based Image Super-Resolution》——…...

9--苍穹外卖-SpringBoot项目中Redis的介绍及其使用实例 详解

目录 Redis入门 Redis简介 Redis服务启动与停止 服务启动命令 Redis数据类型 5种常用数据类型介绍 各种数据类型的特点 Redis常用命令 字符串操作命令 哈希操作命令 列表操作命令 集合操作命令 有序集合操作命令 通用命令 在java中操作Redis Redis的Java客户端 …...

【EXCEL数据处理】000014 案例 EXCEL分类汇总、定位和创建组。附多个操作案例。

前言&#xff1a;哈喽&#xff0c;大家好&#xff0c;今天给大家分享一篇文章&#xff01;创作不易&#xff0c;如果能帮助到大家或者给大家一些灵感和启发&#xff0c;欢迎收藏关注哦 &#x1f495; 目录 【EXCEL数据处理】000014 案例 EXCEL分类汇总、定位和创建组。附多个操…...

Windows环境Apache httpd 2.4 web服务器加载PHP8:Hello,world!

Windows环境Apache httpd 2.4 web服务器加载PHP8&#xff1a;Hello&#xff0c;world&#xff01; &#xff08;1&#xff09;首先需要安装apache httpd 2.4 web服务器&#xff1a; Windows安装启动apache httpd 2.4 web服务器-CSDN博客文章浏览阅读222次&#xff0c;点赞5次&…...

Spring框架使用Api接口实现AOP的切面编程、两种方式的程序示例以及Java各数据类型及基本数据类型的默认值/最大值/最小值列表

一、Spring框架使用Api接口-继承类实现AOP的切面编程示例 要使用Spring框架AOP&#xff0c;除了要导入spring框架包外&#xff0c;还需要导入一个织入的包org.aspectj&#xff0c;具体maven依赖如下&#xff1a; <dependency><groupId>org.springframework</gr…...

【达梦数据库】尽可能 disql 的使用效果与异构数据库一致

文章目录 前言disql 效果优化参数设置参数说明 mysql参数设置参数说明 db2参数设置参数说明 待补充 前言 让达梦的disql 使用起来更跟手&#xff0c;与其他优质数据库的命令行工具通过配置参数的方式尽可能一致&#xff0c;提高使用体验&#xff0c;长期整理中~~~ 测试版本&…...

【研1深度学习】《神经网络和深度学习》阅读笔记(记录中......

9.27 语义鸿沟&#xff1a; 是指输入数据的底层特征和高层语义信息之间的不一致性和查一下。如果可以有一个好的表示在某种程度上能够反映出数据的高层语义特征&#xff0c;那么我们就能相对容易的构建后续的机器学习模型。嵌入&#xff08;Embedding&#xff09;&#xff1a;…...

十一不停歇-学习ROS2第一天 (10.2 10:45)

话题通信 1.1 发布第一个节点&#xff1a; import rclpy #导入此类模块 rcl类型 from rclpy.node import Node #从这个子模块中导入这类函数 def main(): #定义这个函数 rclpy.init() #使用初始化函数 node Node(hello_python) 将类函数里面的内容调给…...

Java高效编程(14):考虑实现 `Comparable

解锁Python编程的无限可能&#xff1a;《奇妙的Python》带你漫游代码世界 与其他方法不同&#xff0c;compareTo 并非 Object 类中声明的&#xff0c;而是 Comparable 接口的唯一方法。compareTo 方法与 equals 类似&#xff0c;但它不仅支持相等性比较&#xff0c;还允许顺序…...

华为昇腾CANN训练营2024第二季--Ascend C算子开发能力认证(中级)题目和经验分享

大家好&#xff0c;我是刘明&#xff0c;明志科技创始人&#xff0c;华为昇思MindSpore布道师。 技术上主攻前端开发、鸿蒙开发和AI算法研究。 努力为大家带来持续的技术分享&#xff0c;如果你也喜欢我的文章&#xff0c;就点个关注吧 正文开始 华为昇腾CANN训练营2024第二季…...

实战OpenCV之形态学操作

基础入门 形态学操作是一种基于图像形状的处理方法,主要用于结构分析,比如:边缘检测、轮廓提取、噪声去除等。这些操作通常使用一个称为“结构元素”(Structuring Element)的核来进行,结构元素可以是任何形状,但最常见的有矩形和圆形。形态学操作的核心在于通过结构元素…...

矩阵的特征值和特征向量

矩阵的特征值和特征向量是线性代数中非常重要的概念&#xff0c;用于描述矩阵对向量的作用&#xff0c;特别是在矩阵对向量的线性变换中的表现。它们帮助我们理解矩阵在某些方向上的缩放或旋转效果。 1. 特征值和特征向量的定义&#xff1a; 给定一个 n n n \times n nn 的…...

(11)MATLAB莱斯(Rician)衰落信道仿真2

文章目录 前言一、莱斯衰落信道仿真模型二、仿真代码与结果1.仿真代码2.仿真结果画图 三、后续&#xff1a;四、参考文献&#xff1a; 前言 首先给出莱斯衰落信道仿真模型&#xff0c;该模型由直射路径分量和反射路径分量组成&#xff0c;其中反射路径分量由瑞利衰落信道模型构…...

ComfyUI局部重绘换衣讲解

一、下载插件 ComfyUI-Impact-Pack 下载地址 https://github.com/ltdrdata/ComfyUI-Impact-Pack 主要用到sam Detector去绘制衣服蒙版和高斯模糊蒙版&#xff0c;高斯模糊让蒙版边缘更加柔和 sams模型 放在E:\Comfyui\ComfyUI\models\sams二、换衣思路 文生图或直接上传…...

Android——添加联系人

概述 方式一&#xff1a;使用ContentResolver多次写入&#xff0c;每次写入一个字段 第一步 往手机联系人应用中的raw_contacts表添加一条记录 raw_contacts表 ContentValues values new ContentValues();// 往 raw_contacts 添加联系人记录&#xff0c;并获取添加后的联…...

高级 Java Redis 客户端 有哪些?

高级Java Redis客户端主要包括以下几种&#xff1a; 1. Redisson &#xff08;https://github.com/redisson/redisson&#xff09; 特点&#xff1a;Redisson是一个在Redis的基础上实现的Java驻留数据网格&#xff08;In-Memory Data Grid&#xff09;。它不仅是一个Redis的J…...

jenkins项目发布基础

随着软件开发需求及复杂度的不断提高,团队开发成员之间如何更好地协同工作以确保软件开发的质量已经慢慢成为开发过程中不可回避的问题。Jenkins 自动化部署可以解决集成、测试、部署等重复性的工作,工具集成的效率明显高于人工操作;并且持续集成可以更早的获取代码变更的信息,…...

前缀和算法详解

对于查询区间和的问题&#xff0c;可以预处理出来一个前缀和数组 dp&#xff0c;数组中存储的是从下标 0 的位置到当前位置的区间和&#xff0c;这样只需要通过前缀和数组就可以快速的求出指定区间的和了&#xff0c;例如求 l ~ r 区间的和&#xff0c;就可以之间使用 dp[l - 1…...

Android-Handle消息传递和线程通信

本文为作者学习笔记&#xff0c;如有误&#xff0c;请各位大佬指点 目录 一、同步异步 二、Java多线程通信 三、Handler是什么 四、Handler相关的类 五、Handler常用方法 1. 发送消息 2. 接收处理消息 3. 切换线程 六、使用Handler 使用Handler更新UI 使用Handler延…...

多模态2025:技术路线“神仙打架”,视频生成冲上云霄

文&#xff5c;魏琳华 编&#xff5c;王一粟 一场大会&#xff0c;聚集了中国多模态大模型的“半壁江山”。 智源大会2025为期两天的论坛中&#xff0c;汇集了学界、创业公司和大厂等三方的热门选手&#xff0c;关于多模态的集中讨论达到了前所未有的热度。其中&#xff0c;…...

基于uniapp+WebSocket实现聊天对话、消息监听、消息推送、聊天室等功能,多端兼容

基于 ​UniApp + WebSocket​实现多端兼容的实时通讯系统,涵盖WebSocket连接建立、消息收发机制、多端兼容性配置、消息实时监听等功能,适配​微信小程序、H5、Android、iOS等终端 目录 技术选型分析WebSocket协议优势UniApp跨平台特性WebSocket 基础实现连接管理消息收发连接…...

Java多线程实现之Thread类深度解析

Java多线程实现之Thread类深度解析 一、多线程基础概念1.1 什么是线程1.2 多线程的优势1.3 Java多线程模型 二、Thread类的基本结构与构造函数2.1 Thread类的继承关系2.2 构造函数 三、创建和启动线程3.1 继承Thread类创建线程3.2 实现Runnable接口创建线程 四、Thread类的核心…...

嵌入式学习笔记DAY33(网络编程——TCP)

一、网络架构 C/S &#xff08;client/server 客户端/服务器&#xff09;&#xff1a;由客户端和服务器端两个部分组成。客户端通常是用户使用的应用程序&#xff0c;负责提供用户界面和交互逻辑 &#xff0c;接收用户输入&#xff0c;向服务器发送请求&#xff0c;并展示服务…...

搭建DNS域名解析服务器(正向解析资源文件)

正向解析资源文件 1&#xff09;准备工作 服务端及客户端都关闭安全软件 [rootlocalhost ~]# systemctl stop firewalld [rootlocalhost ~]# setenforce 0 2&#xff09;服务端安装软件&#xff1a;bind 1.配置yum源 [rootlocalhost ~]# cat /etc/yum.repos.d/base.repo [Base…...

Kafka主题运维全指南:从基础配置到故障处理

#作者&#xff1a;张桐瑞 文章目录 主题日常管理1. 修改主题分区。2. 修改主题级别参数。3. 变更副本数。4. 修改主题限速。5.主题分区迁移。6. 常见主题错误处理常见错误1&#xff1a;主题删除失败。常见错误2&#xff1a;__consumer_offsets占用太多的磁盘。 主题日常管理 …...

保姆级【快数学会Android端“动画“】+ 实现补间动画和逐帧动画!!!

目录 补间动画 1.创建资源文件夹 2.设置文件夹类型 3.创建.xml文件 4.样式设计 5.动画设置 6.动画的实现 内容拓展 7.在原基础上继续添加.xml文件 8.xml代码编写 (1)rotate_anim (2)scale_anim (3)translate_anim 9.MainActivity.java代码汇总 10.效果展示 逐帧…...

论文阅读:Matting by Generation

今天介绍一篇关于 matting 抠图的文章&#xff0c;抠图也算是计算机视觉里面非常经典的一个任务了。从早期的经典算法到如今的深度学习算法&#xff0c;已经有很多的工作和这个任务相关。这两年 diffusion 模型很火&#xff0c;大家又开始用 diffusion 模型做各种 CV 任务了&am…...

Unity VR/MR开发-VR开发与传统3D开发的差异

视频讲解链接&#xff1a;【XR马斯维】VR/MR开发与传统3D开发的差异【UnityVR/MR开发教程--入门】_哔哩哔哩_bilibili...

【Java】Ajax 技术详解

文章目录 1. Filter 过滤器1.1 Filter 概述1.2 Filter 快速入门开发步骤:1.3 Filter 执行流程1.4 Filter 拦截路径配置1.5 过滤器链2. Listener 监听器2.1 Listener 概述2.2 ServletContextListener3. Ajax 技术3.1 Ajax 概述3.2 Ajax 快速入门服务端实现:客户端实现:4. Axi…...