UE5.1_自定义配置文件读取
读取配置文件时常规项目都会要求考虑的一个问题,然我接触过的UE类项目还真没考虑过,最近有个想法,奈何比较费劲,利用网上的教程跟进一下试试?
先基于Actor创建c++类(应该大家都会的吧),然后就是一下代码:
MyConfig.h
// Fill out your copyright notice in the Description page of Project Settings.#pragma once#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MyConfig.generated.h"UCLASS()
class DIGITALVISUALIZATION_API AMyConfig : public AActor
{GENERATED_BODY()public:TMap<FString, FString> ConfigMap;public: // Sets default values for this actor's propertiesAMyConfig();protected:// Called when the game starts or when spawnedvirtual void BeginPlay() override;public: // Called every framevirtual void Tick(float DeltaTime) override;public:void LoadConfigFile();UFUNCTION(BlueprintCallable, Category = "Config")FString GetValueForKey(const FStr