If anyone ever will find themselves facing the same situation, here is the answer:
- In your .h file create a struct for you replay info. It is needed to create a file and if you wish so, rename or delete it. It is saved in ProjectDir/Saved/Demos/.replayinfo
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(FString NewName, FString NewFriendlyName, FDateTime NewTimestamp, int32 NewLengthInMS)
{
ReplayName = NewName;
FriendlyName = NewFriendlyName;
Timestamp = NewTimestamp;
LengthInMS = NewLengthInMS;
bIsValid = true;
}
FS_ReplayInfo()
{
ReplayName = "Replay";
FriendlyName = "Replay";
Timestamp = FDateTime::MinValue();
LengthInMS = 0;
bIsValid = false;
}
};
- In the same .h file create these variables and functions
public:
//ooking for/finding replays on hard drive
UFUNCTION(BlueprintCallable, Category = Replays)
void FindReplays();
virtual void Init() override;
private:
// helper function for FindReplays()
TSharedPtr<INetworkReplayStreamer> EnumerateStreamsPtr;
FOnEnumerateStreamsComplete OnEnumerateStreamsCompleteDelegate;
void OnEnumerateStreamsComplete(const TArray<FNetworkReplayStreamInfo>& StreamInfos);
- Define functionality and update/create Init(0
void UReplay::Init()
{
Super::Init();
// create a ReplayStreamer for FindReplays() and DeleteReplay(..)
EnumerateStreamsPtr = FNetworkReplayStreaming::Get().GetFactory().CreateReplayStreamer();
// Link FindReplays() delegate to function
OnEnumerateStreamsCompleteDelegate = FOnEnumerateStreamsComplete::CreateUObject(this, &UReplay::OnEnumerateStreamsComplete);
}
void UReplay::FindReplays()
{
if (EnumerateStreamsPtr.Get())
{
EnumerateStreamsPtr.Get()->EnumerateStreams(FNetworkReplayVersion(), 0, FString(), TArray<FString>(), FEnumerateStreamsCallback());// OnEnumerateStreamsCompleteDelegate was here, check if it's still needed
}
}
- Create blueprint (can be any class really) and add following nodes
- Get yourself a nice cup of tea and keep going with a good work!