UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
AssetDependencyGatherer.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#if WITH_EDITOR
6
9#include "Containers/Array.h"
10#include "Containers/List.h"
13#include "UObject/NameTypes.h"
14#include "UObject/Object.h"
16
18class FString;
19class UClass;
21struct FARFilter;
22struct FAssetData;
23class FPathTree;
24template <typename FuncType> class TFunctionRef;
25
26namespace UE::AssetDependencyGatherer::Private
27{
29};
30
31namespace UE::AssetRegistry
32{
33 class FAssetRegistryImpl;
34}
40{
41public:
43 {
44 FName PackageName;
46 };
47
48 /* The parameters passed to GatherDependencies
49 *
50 * @param AssetData The Asset to which the dependencies will be added
51 * @param AssetRegistryState Helper object: The AssetRegistry's internal state which can be used to run queries
52 * in the callback. This must be used instead of the usual interface functions on
53 * IAssetRegistry::GetChecked(), because the callback executes inside the critical section.
54 * @param CompileFilterFunc Helper object: Used to compile FARFilter into FARCompiledFilter for queries sent to
55 * AssetRegistryState. The same functionality that is normally provided by
56 * IAssetRegistry::GetChecked().CompileFilter.
57 * @param CachedPathTree The path tree cache inside the AssetRegitry can be used to quickly interogate the path
58 * hierarchy.
59 * @param OutDependencies List of gathered dependencies to add for the asset.
60 * @param OutDependencyDirectories List of directories that the callback queried. The AssetRegistry will call the callback
61 * again if any assets are added to any of these directories.
62 */
64 {
66 friend class IAssetDependencyGatherer;
67 friend class UE::AssetDependencyGatherer::Private::FRegisteredAssetDependencyGatherer;
68
69 private:
70
71 const FAssetData& AssetData;
73 const FPathTree& CachedPathTree;
75 TArray<FGathereredDependency>& OutDependencies;
77
78 // helper flag to detect old implementations of IAssetDependencyGatherer
80
81 public:
82
88 CachedPathTree(InCachedPathTree),
90 OutDependencies(InReturnedDependencies),
92 {
93 }
94
95 const FAssetData& GetAssetData() const { return AssetData; }
97 const class FPathTree& GetCachedPathTree() const { return CachedPathTree; }
99 FARCompiledFilter CompileFilter(FARFilter& Filter) { return CompileFilterFunc(Filter); }
100
101 TArray<FGathereredDependency>& GetOutDependencies() { return OutDependencies; }
103 };
104
117
122 UE_DEPRECATED(5.8, "Implement GatherDependencies(FGatherDependenciesContext& Context) instead")
125 TArray<FString>& OutDependencyDirectories) const /*= 0*/;
126
127};
128
130{
132 {
133 public:
136
139
140 virtual UClass* GetAssetClass() const = 0;
141 virtual void GatherDependencies(IAssetDependencyGatherer::FGatherDependenciesContext& Context) const = 0;
142
144 static bool IsEmpty() { return !GetRegisteredList(); }
145
146 ASSETREGISTRY_API void GatherDependenciesForGatherer(IAssetDependencyGatherer* GathererInterface, IAssetDependencyGatherer::FGatherDependenciesContext& Context, const char* InGathererClass) const;
147 private:
148
151 mutable bool bCalledOnce = false;
152 };
153}
154
155
164#define REGISTER_ASSETDEPENDENCY_GATHERER(GathererClass, AssetClass) \
165class PREPROCESSOR_JOIN(PREPROCESSOR_JOIN(GathererClass, AssetClass), _Register) : public UE::AssetDependencyGatherer::Private::FRegisteredAssetDependencyGatherer \
166{ \
167 virtual UClass* GetAssetClass() const override { return AssetClass::StaticClass(); } \
168 virtual void GatherDependencies(IAssetDependencyGatherer::FGatherDependenciesContext& Context) const override \
169 { \
170 GathererClass Gatherer; \
171 GatherDependenciesForGatherer(&Gatherer, Context, #GathererClass); \
172 } \
173}; \
174namespace PREPROCESSOR_JOIN(GathererClass, AssetClass) \
175{ \
176 static PREPROCESSOR_JOIN(PREPROCESSOR_JOIN(GathererClass, AssetClass), _Register) DefaultObject; \
177}
178
179#endif // WITH_EDITOR
EForEachResult ForEach(T &Array, const PREDICATE_CLASS &Predicate)
Definition AISense_Sight.cpp:60
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define DECLARE_MULTICAST_DELEGATE(DelegateName)
Definition DelegateCombinations.h:23
Definition AssetRegistryState.h:158
Definition NameTypes.h:617
Definition PathTree.h:13
Definition Array.h:670
Definition AssetRegistryState.h:50
Definition List.h:285
Definition Class.h:3793
Definition AssetRegistryImpl.h:394
@ AssetData
Definition TokenizedMessage.h:40
Definition OverriddenPropertySet.cpp:45
Definition PackageReader.h:15
EDependencyProperty
Definition AssetRegistryInterface.h:88
Definition AdvancedWidgetsModule.cpp:13
Definition ARFilter.h:193
Definition ARFilter.h:23
Definition AssetData.h:162