Appearance
Visual resolvers and previews
Static presentation fragments
Item definitions can contain text, 2D icon, and world-mesh fragments. Your widget or world actor reads these and creates the representation.
URicItemFragmentWorldMesh references a static or skeletal mesh and MeshScale. It does not automatically spawn a pickup actor.
Visual resolver
URicVisualResolver produces item name, description, icon dimensions, and a dynamic material instance. Configure its class with URicItemFragmentVisualResolver.
Public getters are GetName_Resolver(), GetDescription(), GetSize(), and GetMaterialInstance().
Extension hooks include OnInit, OnRefresh, OnGameplayStatTagChanged, OnDestroy, GetItemName, GetItemDescription, GetIconSize, and GetDynamicMaterialInstance.
The default text getters read the text fragment. The default icon size is 100 × 100; the default dynamic material is null. A custom resolver supplies rendered-icon behavior.
Resolve through the cache
cpp
#include "Fragments/Item/RicItemFragmentVisualResolver.h"
#include "Visuals/RicVisualResolver.h"
#include "Instances/RicItemInstance.h"
URicVisualResolver* GetInventoryResolver(
UObject* Context, URicItemInstance* Item)
{
if (!Context || !Item)
{
return nullptr;
}
const URicItemFragmentVisualResolver* Fragment =
Item->FindFragment<URicItemFragmentVisualResolver>();
return Fragment ? Fragment->FindOrConstructVisualResolver(
Context, 0, Item) : nullptr;
}The helper uses context 0 as a project-defined inventory role. Use different uint8 contexts when the same item needs separate resolver state for a tooltip or inspection panel.
URicVisualResolverSubsystem caches by item GUID and context. Before a GUID exists, it uses separate instance entries and promotes them when identity becomes available. It can rebind an existing resolver to the current representation of the same item.
Keep resolver state appropriate to the item/context. Sharing the whole resolver by item definition would rebind its item subscriptions. Share identical render resources separately.
Choose the preview mode
The RicPreview client module supplies URicPreviewSubsystem, a game-instance subsystem.
Use OpenPreview() for an isolated inspection window. Each handle owns a separate preview world.
Use FindOrCreateInventoryPreview() for cached icons. Entries share one inventory preview world and lighting rig, while each entry has its own actor, camera, and render target.
Shared inventory preview
The following helper assumes a client context and valid actor classes:
cpp
#include "RicPreviewSubsystem.h"
#include "Engine/GameInstance.h"
FRicPreviewHandle GetItemPreview(
UGameInstance* GameInstance,
FName Key,
TSubclassOf<AActor> ItemActorClass,
TSubclassOf<AActor> LightingClass,
bool& bCreated)
{
bCreated = false;
URicPreviewSubsystem* Previews = GameInstance
? GameInstance->GetSubsystem<URicPreviewSubsystem>() : nullptr;
if (!Previews)
{
return {};
}
return Previews->FindOrCreateInventoryPreview(
Key, ItemActorClass, LightingClass, FIntPoint(256, 256),
bCreated, 200.f, 45.f, false);
}A nonempty key is required. Use a type key for identical visuals or an item GUID converted to FName for unique attachments or appearance.
When bCreated is true, initialize Handle.DisplayedActor with the item/meshes. Then call RefreshPreview(Handle). Bind Handle.RenderTarget to your material. Retain the handle/material through reflected properties where needed.
Existing names return the original preview and settings. A later call with a different resolution or actor class does not create a separate entry with that same name.
Capture scheduling
Shared captures are queued and repeated refresh requests for an entry are coalesced. Default MaxInventoryCapturesPerFrame is 1. A render target exists on creation, but the finished image is not available synchronously on that call.
Use RefreshPreview() after visual or camera changes. Avoid calling CaptureScene() directly for shared entries because it bypasses scheduling.
Actor construction is synchronous. Spread expensive preview actor initialization across frames if your inventory creates many unique icons at once.
InventoryPreviewSpacing defaults to 10000 Unreal units and should be configured before entries are created. Captures use show-only geometry: attach child actors and attachments to the displayed hierarchy so they are included.
The first lighting class creates a shared rig. Later entries reuse it until world cleanup. Geometry isolation does not create independent lighting environments.
Tick behavior
Set bTickWorld for previews needing animation, timers, or latent actions. For static or event-driven item rendering, leave it disabled.
The shared world ticks while any active entry requests ticking. All entries belong to that same world.
Lifetime and resource sharing
ClosePreview(Handle) removes an inventory name and queues its actors for removal; other entries survive. For an isolated handle, it releases the isolated world.
ClearInventoryPreviews() retires inventory entries gradually while retaining the shared world. Cleanup() releases shared and isolated previews.
The name cache is not reference counted. Closing a shared entry affects every consumer using it. Coordinate ownership so one resolver does not retire a preview still used elsewhere.
Entries remain cached until explicitly retired; there is no automatic memory cap. Reuse handles across UI openings when appropriate and retire unused entries. Stale handles cannot operate on a newly created replacement with the same name.
Isolated inspection preview
cpp
FRicPreviewHandle Handle = Previews->OpenPreview(
ItemActorClass, LightingClass, FIntPoint(512, 512),
200.f, 45.f, true, FName(TEXT("Inspection")));Initialize its actor, refresh after changes, and close when the inspection session ends. Use SetPreviewActorClass() when replacing the inspected actor without replacing the world/capture.
Preview rendering does not implement equipment simulation or weapon effects. Your actor and resolver supply the appropriate visual state.