Zum Hauptinhalt springen

UI Helpers

The UI layer helps resolve registered assets and construct a drag/drop payload. It does not supply a complete inventory, weapon-workbench widget or atomic inventory transfer.

Source: Public/System/AsyncResolveWeaponAsset.h, Public/System/WeaponUIHelper.h, Public/UI and their Private implementations.

AsyncResolveWeaponAsset​

UAsyncResolveWeaponAsset is a UBlueprintAsyncActionBase. The Blueprint node takes FName ItemID and reports Completed(bool bValidResult, bool bIsMaster, UPrimaryDataAsset* LoadedAsset).

It gets the current play world, Game Instance, subsystem and data manager, resolves the ID's registered type, and loads the master/part soft reference through the streamable manager. Successful completion also updates the corresponding loaded cache.

Failure reports (false, false, nullptr). Only WeaponMaster and WeaponPart are supported by this node; modifier, side-effect and FX IDs do not use an equivalent branch here.

The node takes no WorldContextObject and uses GEngine.GetCurrentPlayWorld. Verify behavior in multi-world PIE rather than assuming it selects any caller's world. Complete database initialization first and check bValidResult before casting LoadedAsset.

CreateWeaponPartDragDropOp​

UWeaponUIHelper exposes a BlueprintCallable function under Weapon Subsystem|BP Lib|UI.

InputTypePurpose
PlayerControllerAPlayerController pointerWidget owner and world
PartTypeEWeaponPartTypeMainPart or AttachmentPart
LoadedDataAssetUPrimaryDataAsset pointerAlready loaded master or part
Slateconst FSlateBrush referenceSupplies visual texture resource
VisualPivotEDragPivotDrag visual pivot

The return is UDragDropOperation with bSucceed and FailureReason outputs. Configure UWeaponSettings.DragVisual to a UWeaponDragVisual subclass.

The helper creates UWeaponPartPayload containing PartType, PartID and Data, loads the visual class synchronously, creates its widget and assigns PayloadTexture if the brush resource is a UTexture2D. The operation stores that payload and DefaultDragVisual.

Widget Contracts​

UWeaponDragVisual is a Blueprintable UUserWidget with PayloadTexture. Its Blueprint implements the appearance. UWeaponPartPayload is a Blueprintable UObject; it represents the dragged definition, not a persisted build or an accepted inventory transaction.

On drop, interpret the payload in your widget, queue the appropriate build edit and wait for mutation/validation. Update inventory state according to your own transfer rules.

Current Input Constraints​

Pass a valid controller and an actual master/part asset. The helper records a null-controller error but immediately dereferences the controller to check its world. Its non-master branch assumes the asset can be cast to UPDA_WeaponPart. Therefore null controllers and unrelated UPrimaryDataAsset types are unsafe inputs rather than guaranteed clean error results.

The drag visual class is loaded synchronously during drag construction. Preload/configure it before frequent interactions if loading latency matters. See Implementation Limits.