43 static void DumpLoadedAssets();
52 static void RegisterBundleAssets(
const TArray<UObject*>& InAssets);
61 static void UnregisterBundleAssets(
const TArray<UObject*>& InAssets);
65 template <
typename TData>
66 static TData*
GetAsset(
const TSoftObjectPtr<TData>& AssetPointer,
bool bKeepInMemory =
true);
68 template <
typename TData>
69 static TSubclassOf<TData>
GetSubclass(
const TSoftClassPtr<TData>& AssetPointer,
bool bKeepInMemory =
true);
71 static void LoadAsyncByPath(
const FSoftObjectPath& AssetPath, FAsyncLoadCompletedDelegate CompletedDelegate = FAsyncLoadCompletedDelegate());
72 static void LoadAsyncByName(
const FName& AssetName, FAsyncLoadCompletedDelegate CompletedDelegate = FAsyncLoadCompletedDelegate());
76 static UObject* SynchronousLoadAsset(
const FSoftObjectPath& AssetPath);
77 static bool ShouldLogAssetLoads();
79 template <
typename TData>
82 template <
typename TData>
87 UFUNCTION(BlueprintNativeEvent, Category =
"DataAssetManager")
88 void InitializeOnManager();
90 UFUNCTION(BlueprintNativeEvent, Category = "DataAssetManager")
91 void OnUpdateLoadPercentage(
float Percentage);
93 UFUNCTION(BlueprintNativeEvent, Category = "DataAssetManager")
94 void OnAllDataLoadCompleted();
96 virtual
void TryCreateLoadJobForDataAsset(TSoftObjectPtr<UPrimaryDataAsset> DataPath, FString
JobName);
97 virtual
void StartInitialLoading() override;
99 UPrimaryDataAsset* LoadGameDataOfClass(TSubclassOf<UPrimaryDataAsset> DataClass, const TSoftObjectPtr<UPrimaryDataAsset>& DataClassPath, FPrimaryAssetType PrimaryAssetType);
103 virtual void PreBeginPIE(
bool bStartSimulate)
override;
110 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "GameData")
111 TArray<TSoftObjectPtr<UPrimaryDataAsset>> InitialGameDataPaths;
117 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "DataAssetManager", meta = (AllowPrivateAccess = "true"))
118 TSet<TObjectPtr<UObject>> LoadedAssets;
127 AssetType* LoadedAsset =
nullptr;
128 const FSoftObjectPath& AssetPath = AssetPointer.ToSoftObjectPath();
130 if (AssetPath.IsNull())
135 LoadedAsset = AssetPointer.Get();
137 if (LoadedAsset ==
nullptr)
140 ensureAlwaysMsgf(LoadedAsset, TEXT(
"Failed to load asset [%s]"), *AssetPointer.ToString());
143 if (LoadedAsset && bKeepInMemory)
155 TSubclassOf<AssetType> LoadedSubclass;
156 const FSoftObjectPath& AssetPath = AssetPointer.ToSoftObjectPath();
158 if (AssetPath.IsNull())
160 return LoadedSubclass;
163 LoadedSubclass = AssetPointer.Get();
165 if (LoadedSubclass ==
nullptr)
168 ensureAlwaysMsgf(LoadedSubclass, TEXT(
"Failed to load asset class [%s]"), *AssetPointer.ToString());
171 if (LoadedSubclass && bKeepInMemory)
176 return LoadedSubclass;
183 if (
auto* pResult =
GameDataMap.Find(GameDataClass::StaticClass()))
185 if (pResult->Assets.IsEmpty() ==
false)
187 return *CastChecked<GameDataClass>(pResult->Assets[0]);
191 return *CastChecked<const GameDataClass>(
LoadGameDataOfClass(GameDataClass::StaticClass(), DataPath, GameDataClass::StaticClass()->GetFName()));
UPrimaryDataAsset * LoadGameDataOfClass(TSubclassOf< UPrimaryDataAsset > DataClass, const TSoftObjectPtr< UPrimaryDataAsset > &DataClassPath, FPrimaryAssetType PrimaryAssetType)
지정한 클래스 타입의 게임 데이터 에셋을 동기 로드하고 GameDataMap에 등록합니다.
Definition DataAssetManager.cpp:315