UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
InterchangeUserDefinedAttribute.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Containers/Array.h"
7#include "HAL/Platform.h"
8#include "HAL/PlatformCrt.h"
10#include "Misc/Optional.h"
13#include "UObject/Class.h"
14#include "UObject/Object.h"
17
18#include "InterchangeUserDefinedAttribute.generated.h"
19
20struct FFrame;
22
23USTRUCT(BlueprintType)
25{
27
28 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Interchange | Node | UserDefinedAttributeInfo")
29 FString Name;
30
31 UE::Interchange::EAttributeTypes Type;
32
33 TOptional<FString> PayloadKey;
34
35 bool RequiresDelegate;
36};
37
43UCLASS(BlueprintType, MinimalAPI)
45{
47
48public:
49
58 template<typename ValueType>
59 static bool CreateUserDefinedAttribute(UInterchangeBaseNode* InterchangeNode, const FString& UserDefinedAttributeName, const ValueType& Value, const TOptional<FString>& PayloadKey, bool RequiresDelegate = false);
60
61 UFUNCTION(BlueprintCallable, Category = "Interchange | Node | UserDefinedAttribute")
62 static INTERCHANGECORE_API bool CreateUserDefinedAttribute_Boolean(UInterchangeBaseNode* InterchangeNode, const FString& UserDefinedAttributeName, const bool& Value, const FString& PayloadKey, bool RequiresDelegate = false);
63
64 UFUNCTION(BlueprintCallable, Category = "Interchange | Node | UserDefinedAttribute")
65 static INTERCHANGECORE_API bool CreateUserDefinedAttribute_Float(UInterchangeBaseNode* InterchangeNode, const FString& UserDefinedAttributeName, const float& Value, const FString& PayloadKey, bool RequiresDelegate = false);
66
67 UFUNCTION(BlueprintCallable, Category = "Interchange | Node | UserDefinedAttribute")
68 static INTERCHANGECORE_API bool CreateUserDefinedAttribute_Double(UInterchangeBaseNode* InterchangeNode, const FString& UserDefinedAttributeName, const double& Value, const FString& PayloadKey, bool RequiresDelegate = false);
69
70 UFUNCTION(BlueprintCallable, Category = "Interchange | Node | UserDefinedAttribute")
71 static INTERCHANGECORE_API bool CreateUserDefinedAttribute_Int32(UInterchangeBaseNode* InterchangeNode, const FString& UserDefinedAttributeName, const int32& Value, const FString& PayloadKey, bool RequiresDelegate = false);
72
73 UFUNCTION(BlueprintCallable, Category = "Interchange | Node | UserDefinedAttribute")
74 static INTERCHANGECORE_API bool CreateUserDefinedAttribute_FString(UInterchangeBaseNode* InterchangeNode, const FString& UserDefinedAttributeName, const FString& Value, const FString& PayloadKey, bool RequiresDelegate = false);
75
83 UFUNCTION(BlueprintCallable, Category = "Interchange | Node | UserDefinedAttribute")
84 static INTERCHANGECORE_API bool RemoveUserDefinedAttribute(UInterchangeBaseNode* InterchangeNode, const FString& UserDefinedAttributeName);
85
94 template<typename ValueType>
95 static bool GetUserDefinedAttribute(const UInterchangeBaseNode* InterchangeNode, const FString& UserDefinedAttributeName, ValueType& OutValue, TOptional<FString>& OutPayloadKey);
96
97 UFUNCTION(BlueprintCallable, Category = "Interchange | Node | UserDefinedAttribute")
98 static INTERCHANGECORE_API bool GetUserDefinedAttribute_Boolean(const UInterchangeBaseNode* InterchangeNode, const FString& UserDefinedAttributeName, bool& OutValue, FString& OutPayloadKey);
99
100 UFUNCTION(BlueprintCallable, Category = "Interchange | Node | UserDefinedAttribute")
101 static INTERCHANGECORE_API bool GetUserDefinedAttribute_Float(const UInterchangeBaseNode* InterchangeNode, const FString& UserDefinedAttributeName, float& OutValue, FString& OutPayloadKey);
102
103 UFUNCTION(BlueprintCallable, Category = "Interchange | Node | UserDefinedAttribute")
104 static INTERCHANGECORE_API bool GetUserDefinedAttribute_Double(const UInterchangeBaseNode* InterchangeNode, const FString& UserDefinedAttributeName, double& OutValue, FString& OutPayloadKey);
105
106 UFUNCTION(BlueprintCallable, Category = "Interchange | Node | UserDefinedAttribute")
107 static INTERCHANGECORE_API bool GetUserDefinedAttribute_Int32(const UInterchangeBaseNode* InterchangeNode, const FString& UserDefinedAttributeName, int32& OutValue, FString& OutPayloadKey);
108
109 UFUNCTION(BlueprintCallable, Category = "Interchange | Node | UserDefinedAttribute")
110 static INTERCHANGECORE_API bool GetUserDefinedAttribute_FString(const UInterchangeBaseNode* InterchangeNode, const FString& UserDefinedAttributeName, FString& OutValue, FString& OutPayloadKey);
111
113
114 UFUNCTION(BlueprintCallable, Category = "Interchange | Node | UserDefinedAttribute")
116
117 UFUNCTION(BlueprintCallable, Category = "Interchange | Node | UserDefinedAttribute")
119
120 static INTERCHANGECORE_API void AddApplyAndFillDelegatesToFactory(UInterchangeFactoryBaseNode* InterchangeFactoryNode, UClass* ParentClass);
121
122 static INTERCHANGECORE_API UE::Interchange::FAttributeKey MakeUserDefinedPropertyValueKey(const FStringView UserDefinedAttributeName, bool RequiresDelegate);
123 static INTERCHANGECORE_API UE::Interchange::FAttributeKey MakeUserDefinedPropertyValueKey(const FString& UserDefinedAttributeName,bool RequiresDelegate);
124
125 static INTERCHANGECORE_API UE::Interchange::FAttributeKey MakeUserDefinedPropertyPayloadKey(const FStringView UserDefinedAttributeName, bool RequiresDelegate);
126 static INTERCHANGECORE_API UE::Interchange::FAttributeKey MakeUserDefinedPropertyPayloadKey(const FString& UserDefinedAttributeName, bool RequiresDelegate);
127
128private:
130 static INTERCHANGECORE_API UE::Interchange::FAttributeKey MakeUserDefinedPropertyKey(const FStringView UserDefinedAttributeName, bool RequiresDelegate, bool GeneratePayloadKey = false);
131 static INTERCHANGECORE_API UE::Interchange::FAttributeKey MakeUserDefinedPropertyKey(const FString& UserDefinedAttributeName,bool RequiresDelegate, bool GeneratePayloadKey = false);
132
133private:
134 static INTERCHANGECORE_API const FString UserDefinedAttributeBaseKey;
135 static INTERCHANGECORE_API const FString UserDefinedAttributeValuePostKey;
136 static INTERCHANGECORE_API const FString UserDefinedAttributePayLoadPostKey;
137 static INTERCHANGECORE_API const FString UserDefinedAttributeDelegateKey;
138};
139
140template<typename ValueType>
142{
144
145 UE::Interchange::FAttributeKey UserDefinedValueKey = MakeUserDefinedPropertyKey(UserDefinedAttributeName, RequiresDelegate);
146 if (InterchangeNode->HasAttribute(UserDefinedValueKey))
147 {
148 return false;
149 }
150
151 UE::Interchange::FAttributeKey UserDefinedPayloadKey = MakeUserDefinedPropertyKey(UserDefinedAttributeName, RequiresDelegate, true);
152 if (InterchangeNode->HasAttribute(UserDefinedPayloadKey))
153 {
154 return false;
155 }
156 //Add the user defined attribute to TMap
157 InterchangeNode->RegisterAttribute<ValueType>(UserDefinedValueKey, Value);
158 if (PayloadKey.IsSet())
159 {
160 InterchangeNode->RegisterAttribute<FString>(UserDefinedPayloadKey, PayloadKey.GetValue());
161 }
162 return true;
163}
164
165template<typename ValueType>
167{
169 bool RequiresDelegate;
170 if (!HasAttribute(InterchangeNode, UserDefinedAttributeName, false, RequiresDelegate))
171 {
172 return false;
173 }
174
175 UE::Interchange::FAttributeKey UserDefinedValueKey = MakeUserDefinedPropertyKey(UserDefinedAttributeName, RequiresDelegate);
176 if (!InterchangeNode->GetAttribute<ValueType>(UserDefinedValueKey.Key, OutValue))
177 {
178 return false;
179 }
180
181 //Payload is optional
182 OutPayloadKey.Reset();
183 UE::Interchange::FAttributeKey UserDefinedPayloadKey = MakeUserDefinedPropertyKey(UserDefinedAttributeName, RequiresDelegate, true);
184 if (InterchangeNode->HasAttribute(UserDefinedPayloadKey))
185 {
186 FString PayloadKeyValue;
187 if (InterchangeNode->GetAttribute<FString>(UserDefinedPayloadKey.Key, PayloadKeyValue))
188 {
189 //Set the optional
191 }
192 else
193 {
194 return false;
195 }
196
197 }
198 return true;
199}
#define check(expr)
Definition AssertionMacros.h:314
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UFUNCTION(...)
Definition ObjectMacros.h:745
#define UCLASS(...)
Definition ObjectMacros.h:776
#define USTRUCT(...)
Definition ObjectMacros.h:746
Definition Array.h:670
Definition Class.h:3793
Definition InterchangeBaseNode.h:195
virtual INTERCHANGECORE_API bool HasAttribute(const UE::Interchange::FAttributeKey &NodeAttributeKey) const
Definition InterchangeBaseNode.cpp:223
Definition InterchangeFactoryBaseNode.h:188
Definition InterchangeUserDefinedAttribute.h:45
static bool GetUserDefinedAttribute(const UInterchangeBaseNode *InterchangeNode, const FString &UserDefinedAttributeName, ValueType &OutValue, TOptional< FString > &OutPayloadKey)
Definition InterchangeUserDefinedAttribute.h:166
static bool CreateUserDefinedAttribute(UInterchangeBaseNode *InterchangeNode, const FString &UserDefinedAttributeName, const ValueType &Value, const TOptional< FString > &PayloadKey, bool RequiresDelegate=false)
Definition InterchangeUserDefinedAttribute.h:141
Definition Object.h:95
Definition AdvancedWidgetsModule.cpp:13
Definition Stack.h:114
Definition InterchangeUserDefinedAttribute.h:25
Definition Optional.h:131
constexpr OptionalType & GetValue()
Definition Optional.h:443
constexpr bool IsSet() const
Definition Optional.h:69
Definition AttributeStorage.h:67