Skip to main content

Fragments (Extensibility)

Interaction fragments provide an extensibility mechanism for interactables without subclassing the widget or the player component.

What is a fragment?

A fragment is an instanced UObject stored on an interactable component:

  • UEDInteractableComponent::InteractionFragments

Base type:

  • UEDInteractionFragment (EditInlineNew, DefaultToInstanced)

Primary use case: UI extension ViewModels

When the player focuses an interactable actor, the player component:

  1. Clears extension ViewModels on the base UEDInteractionViewModel
  2. Iterates InteractionFragments
  3. Calls OnInteractionStarted(...) on each fragment
  4. If the fragment returns a UMVVMViewModelBase*, it is registered as an extension ViewModel

This allows you to:

  • Keep the base widget generic
  • Provide custom per-interactable UI data without rebuilding the base ViewModel

Blueprint usage

  1. Create a Blueprint derived from UEDInteractionFragment.
  2. Implement OnInteractionStarted.
  3. Create and return a custom UMVVMViewModelBase (Blueprint or C++) with the extra fields you need.
  4. Add the fragment to InteractionFragments on your interactable actor.

C++ usage (pattern)

UCLASS()
class UMyInteractionFragment : public UEDInteractionFragment
{
GENERATED_BODY()

public:
virtual UMVVMViewModelBase* OnInteractionStarted_Implementation(UObject* Outer, UEDInteractionViewModel* BaseViewModel) override;
};

Return a ViewModel allocated with NewObject<UMVVMViewModelBase>(Outer, ...) so it has a stable outer and lifetime.