Avatars
Pictures of users for the UI: the default widgets show them in the friends list, the party panel, the invite dialog and the login status, and your own widgets get them the same way.
How it works
- The avatar service of the backend (
IPulseOnlineAvatarService) delivers the picture of a user: pixels (Steamworks), an encoded image or an URL (EOS, Online Services, Steam Web API). - The avatar subsystem (
UPulseOnlineAvatarSubsystem, modulePulseOnlineAvatar, one per game instance) makes a texture of it, downloads URLs itself (http and https; PNG, JPG and BMP) and keeps the textures in memory, one per user and size. Nothing is written to disk. Requests for a picture that is still loading wait for the same query. - A user without a picture (or after a failed download) is asked again after
RetryFailedSeconds. When more thanMaxCachedAvatarspictures are cached, the one not used for the longest time goes first. - Until a picture is there, and when there is none, an avatar shows its fallback: the initials of the display name (first letters of the first and the last word) on a color of its own. The same name always gets the same color (
FallbackColors). - Dedicated servers have no avatar subsystem.
Sizes: Small (about 32 pixels, lists), Medium (about 64, friends and party), Large (about 184, profiles). A service delivers the size closest to it.
Blueprint
| Node | What it does |
|---|---|
Get Pulse Online Avatar(UserId, DisplayName, Size) | Async node: Loaded(Texture, Fallback) or No Picture(Fallback) |
Get User Avatar(User, Size), Get Friend Avatar(Friend, Size), Get Party Member Avatar(Member, Size) | The cached picture, or null while it loads (On Avatar Loaded of the avatar subsystem fires when it is there) or if there is none |
Make Avatar Fallback(DisplayName) | Initials and color for a name |
Clear Avatar Cache (avatar subsystem) | Forgets every picture and every user without one, so they load again |
The widget W_PulseOnlineAvatar (class UPulseOnlineAvatarWidget, module PulseOnlineUI) does all of it: Set User(UserId, DisplayName) shows the fallback right away and the picture once it is there. See UI Widgets.
C++
UPulseOnlineAvatarSubsystem* avatars = UPulseOnlineAvatarSubsystem::Get(this);
avatars->RequestAvatar(FriendNetId, EPulseOnlineAvatarSize::Medium, [weakImage = TWeakObjectPtr<UImage>(Image)](UTexture2D* InTexture)
{
UImage* image = weakImage.Get();
if (image && InTexture)
{
image->SetBrushFromTexture(InTexture);
}
});
// What to show meanwhile, or when the user has no picture
const FPulseOnlineAvatarFallback fallback = Pulse::Online::Avatar::MakeFallback(FriendName);
The callback runs exactly once: before RequestAvatar returns for cached pictures, later for loaded ones, with null for users without a picture and when the game instance shuts down.
Users of a platform
Users of a platform service (a Discord friend, the sender of a Discord invite, a Steam friend) often have no net id at the main backend. Their pictures come from that platform (IPulseOnlinePlatformService::QueryAvatar) and stay in the same cache:
| Call | What it does |
|---|---|
Get Platform Avatar(PlatformName, PlatformUserId, Size) | The cached picture, or null while it loads (On Platform Avatar Loaded fires) or if there is none |
RequestPlatformAvatar(PlatformName, PlatformUserId, Size, Callback) (C++) | Loads it; the callback runs exactly once |
FindCachedPlatformAvatar(PlatformName, PlatformUserId, Size) (C++) | The cached picture, without loading |
PlatformName is the name of the platform (GetPlatformServiceNames of the backend: Steam, Discord, MockPlatform). Without that platform the result is null.
Backends
| Backend | Avatars |
|---|---|
| Mock | A test picture per mock user, drawn at the size asked. bMockAvatars on the Mock backend turns them off (the widgets show initials), PulseOnlineFailNext QueryAvatar lets the next query fail. |
| OSS (Online Subsystem v1) | None yet: OSSv1 has no general avatar interface; platform extensions (Steam, EOS over Steam) will bring them. |
| OSSv2 (Online Services, add-on PulseOnlineOSSv2) | None yet. |
An own backend or extension registers an IPulseOnlineAvatarService (see Backends). It completes QueryAvatar exactly once with BGRA pixels (FPulseOnlineAvatarImage::Pixels, Width, Height), an EncodedImage or an Url, or with the error Pulse.Online.NotFound for a user without a picture.
Settings
Project Settings > Pulse > Online > Avatars: bLoadAvatars, MaxCachedAvatars, RetryFailedSeconds, DownloadTimeoutSeconds, MaxImageSize, FallbackColors (see Settings).