Payback 0.0.1
CK Graduation Project
로딩중...
검색중...
일치하는것 없음
EnvironmentPathRegistry.h
이 파일의 문서화 페이지로 가기
1// Fill out your copyright notice in the Description page of Project Settings.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "Engine/DeveloperSettings.h"
7#include "EnvironmentPathRegistry.generated.h"
8
9
10UCLASS(Config=Game, defaultconfig, meta=(DisplayName="Environment Path Registry"))
11class CK_UE_API UEnvironmentPathRegistry : public UDeveloperSettings
12{
13 GENERATED_BODY()
14
15public:
16 virtual FName GetCategoryName() const override
17 {
18 return TEXT("CK_UE");
19 }
20
21public:
22 // 디렉토리 단위 경로 등록 (폴더 picker)
23 UPROPERTY(EditAnywhere, Config, Category = "Registry", meta=(ContentDir))
24 TMap<FName, FDirectoryPath> DirectoryRegistry;
25
26 // 개별 에셋 경로 등록 (에셋 picker)
27 UPROPERTY(EditAnywhere, Config, Category = "Registry")
28 TMap<FName, FSoftObjectPath> AssetRegistry;
29};
30
31
36FORCEINLINE FString GetEnvironmentPathByKey(const FName& Key)
37{
38 const UEnvironmentPathRegistry* Settings = GetDefault<UEnvironmentPathRegistry>();
39
40 if (const FDirectoryPath* Dir = Settings->DirectoryRegistry.Find(Key))
41 {
42 return Dir->Path;
43 }
44
45 if (const FSoftObjectPath* Asset = Settings->AssetRegistry.Find(Key))
46 {
47 return Asset->ToString();
48 }
49
50 return FString();
51}
52
53
54template <typename T>
55FORCEINLINE TSoftObjectPtr<T> GetEnvironmentSoftPtrByKey(const FName& Key)
56{
57 if (Key.IsNone())
58 {
59 return nullptr;
60 }
61
62 const FString Path = GetEnvironmentPathByKey(Key);
63
64 if (Path.IsEmpty())
65 {
66 return nullptr;
67 }
68
69 const FSoftObjectPath ObjectPath = FSoftObjectPath(Path);
70
71 if (!ObjectPath.IsValid())
72 {
73 return nullptr;
74 }
75
76 return TSoftObjectPtr<T>(ObjectPath);
77}
78
79
80template <typename T>
81FORCEINLINE T* GetEnvironmentAssetByKey(const FName& Key)
82{
83 if (Key.IsNone())
84 {
85 return nullptr;
86 }
87
88 const FString Path = GetEnvironmentPathByKey(Key);
89
90 if (Path.IsEmpty())
91 {
92 return nullptr;
93 }
94 else
95 {
96 return TSoftObjectPtr<T>(FSoftObjectPath(Path)).LoadSynchronous();
97 }
98}
FORCEINLINE TSoftObjectPtr< T > GetEnvironmentSoftPtrByKey(const FName &Key)
Definition EnvironmentPathRegistry.h:55
FORCEINLINE T * GetEnvironmentAssetByKey(const FName &Key)
Definition EnvironmentPathRegistry.h:81
FORCEINLINE FString GetEnvironmentPathByKey(const FName &Key)
Definition EnvironmentPathRegistry.h:36
Definition EnvironmentPathRegistry.h:12
TMap< FName, FDirectoryPath > DirectoryRegistry
Definition EnvironmentPathRegistry.h:24
virtual FName GetCategoryName() const override
Definition EnvironmentPathRegistry.h:16
TMap< FName, FSoftObjectPath > AssetRegistry
Definition EnvironmentPathRegistry.h:28