一、配置动态ini类

InConfigBPLibrary.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "InConfigBPLibrary.generated.h"


UCLASS()
class VISIONPROJECT_API AInConfigBPLibrary : public AActor
{
GENERATED_BODY()

public:
// Sets default values for this actor's properties
AInConfigBPLibrary();

protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;

public:
// Called every frame
virtual void Tick(float DeltaTime) override;

public:
UFUNCTION(BlueprintCallable, Category = "InConfig")
void GetConfigNdiInfo(TArray<FString>& configNDIInfo);

};

InConfigBPLibrary.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "InConfigBPLibrary.h"

// Sets default values
AInConfigBPLibrary::AInConfigBPLibrary()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;

}

// Called when the game starts or when spawned
void AInConfigBPLibrary::BeginPlay()
{
Super::BeginPlay();

}

// Called every frame
void AInConfigBPLibrary::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);

}

void AInConfigBPLibrary::GetConfigNdiInfo(TArray<FString>& configNDIInfo)
{
FString ConfigPath = FPaths::ConvertRelativePathToFull(FPaths::ProjectDir()) + "Config/config.ini";
FString sourcename;
GConfig->GetString(TEXT("NDI"), TEXT("sourcename"), sourcename, ConfigPath);
configNDIInfo.Add(sourcename);
FString machinename;
GConfig->GetString(TEXT("NDI"), TEXT("machinename"), machinename, ConfigPath);
configNDIInfo.Add(machinename);
FString streamname;
GConfig->GetString(TEXT("NDI"), TEXT("streamname"), streamname, ConfigPath);
configNDIInfo.Add(streamname);
}

二、配置ini文件

在项目目录下创建目录及文件 Config/config.ini

添加源名、机器名和流名:

1
2
3
4
[NDI]
sourcename=FORMEASY (HDD1)
machinename=FORMEASY
streamname=HDD1

注:注意:sourcename的设备名和流名之间有空格

三、NDIIO插件复制

将UE5中的plugin下NDIIO插件目录复制到项目plugin下

四、添加关卡蓝图方法

按照下图,在EventBeginPlay后添加NDI配置: