RealDocs

UActorComponent::AddAssetUserData

function Engine Since 4.14
#include "Components/ActorComponent.h"
Access: public Specifiers: virtualoverride

Description

Attaches a `UAssetUserData` payload to this component. Asset user data is a generic extensibility mechanism for associating arbitrary typed data with assets and components without modifying their class.

Caveats & Gotchas

  • Only one instance per `UAssetUserData` subclass is stored — adding a second instance of the same class replaces the first silently. Use `GetAssetUserDataOfClass` to check before adding.
  • The component does not take ownership of garbage-collected lifetime for the user data automatically if it is not also referenced elsewhere — ensure the UAssetUserData object is properly rooted or referenced.

Signature

ENGINE_API virtual void AddAssetUserData(UAssetUserData* InUserData) override;

Parameters

Name Type Description Default
InUserData UAssetUserData* The user data object to attach to this component.

Return Type

void

Example

Attach plugin-specific metadata to a component C++
UMyPluginData* PluginData = NewObject<UMyPluginData>(MyComponent);
PluginData->CustomValue = 42;
MyComponent->AddAssetUserData(PluginData);

Version History

Introduced in: 4.14

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.