Hi Rafael,
Thanks for your response and sorry for my delay. I think I failed to provide proper context in my original post. Unfortunately, I’m looking to get the FAssetData associated with the asset that was used the the Actor Factor that created the actor, not the default constructed FAssetData that results in using the function you posted above.
The default behavior of constructing a FAssetData(UObject*) will return either:
- The package of that object
- The BP that was used to generate that object (this is closer to what I’m looking for but it only handles blueprints)
So if we use a AStaticMeshActor as an example and you use FAssetData(AActor* SomeActor), you will result in either the map’s package or the actor’s external package. Neither will point to the StaticMesh. Further more, the FAssetData constructed is not retrieved through the asset registry but instead constructed, which means that it will not contain any metadata.
In our scenario, we are saving database metadata on each of our static mesh assets (and other assets), then when the actor factories create those assets, we want to be able to consistently trace back to that FAssetData so we can pull the database metadata again.
So currently, what we have to do to solve this is a mix of logic that contains:
- A check for the BrowseToAsset override (in case the asset relationship has been modified)
- A Check for the generated BP class (same as what what the default FAssetData constructor does).
- Finally, a call to GetReferencedContentObjects:
`/**
- Used by the “Sync to Content Browser” right-click menu option in the editor.
- @param Objects Array to add content object references to.
- @return Whether the object references content (all overrides of this function should return true)
/
ENGINE_API virtual bool GetReferencedContentObjects( TArray<UObject>& Objects ) const;`
This works, although it seems like there are even more systems within the engine for relating an object within the world to the assets associated with it. For example, the IComponentAssetBroker interface:
`/**
- This class knows how to get or set the asset on a particular kind of actor component
- One asset type can be associated with multiple component types, but any given component
- type only understands how to be created from a single asset type (for now)
/
class IComponentAssetBroker
{
public:
/* Reports the component class this broker knows how to handle */
//virtual TSubclassOf GetSupportedComponentClass()=0;
/** Reports the asset class this broker knows how to handle /
virtual UClass GetSupportedAssetClass()=0;
/** Assign the assigned asset to the supplied component /
virtual bool AssignAssetToComponent(UActorComponent InComponent, UObject* InAsset)=0;
/** Get the currently assigned asset from the component /
virtual UObject GetAssetFromComponent(UActorComponent* InComponent)=0;
virtual ~IComponentAssetBroker() {}
};`
I’m hoping there could be a centralized method for using all these systems in the appropriate order. Allowing pipelines to integrate directly into UE’s existing mechanics for associating UObject’s to their primary Assets. This could extend beyond actors and components (anim and subscene sections within sequencer).
All the best,
Adam