Table of Contents

Class PlayerProfileModule

Namespace
Titipi.MocaLib

Manages the current player's Firestore profile. Signs in anonymously on first run, caches the UID in PlayerPrefs for subsequent sessions, and stores/loads the profile document. Requires FirebaseModule to be initialized first.

public static class PlayerProfileModule
Inheritance
PlayerProfileModule
Inherited Members

Properties

CurrentProfile

The player's current profile. Updated by Initialize() and SaveProfile(Action, Action<Exception>).

IsInitialized

Whether the module has been successfully initialized and a profile has been loaded.

Initialization

Initialize()

Signs the player in anonymously (or reuses a cached session), then loads or creates their Firestore profile document. Retries up to 2 times on PERMISSION_DENIED errors while the auth token propagates.

Methods

GetAvatar()

Returns the current avatar value (either a "local:{id}" string or a URL).

GetLocalAvatarId()

Returns the integer ID of the local avatar, or -1 if the avatar is a URL or not set.

GetMetadataValue<T>(string, T)

Returns the metadata value for key, cast to T. Returns defaultValue if the key is not found or the conversion fails.

IsLocalAvatar()

Returns true if the current avatar is a local bundled asset.

SaveProfile(Action, Action<Exception>)

Persists CurrentProfile to Firestore using SetOptions.MergeAll, automatically updating the device metadata fields before writing.

SetAvatarUrl(string)

Sets the player's avatar to a remote URL.

SetDisplayName(string)

Sets the player's display name. Falls back to "Anonymous" if newName is blank.

SetLocalAvatar(int)

Sets the player's avatar to a bundled local asset identified by avatarId. Stored as "local:{id}".

SetMetadataValue(string, object)

Sets a key-value pair in the profile's custom metadata dictionary.