Users
You can access user information through both the SteamManager
component and a dedicated SteamUser
component.
Component
The SteamUser
component allows you to cache information about one user, and will automatically update if any information about the user updates. For more details, see the SteamUser
API. This component can be easily synchronized with networking framework integrations via their UserLink
components. See each networking framework integration's documentation for more:
Information
When information such as a user's name or state has updated, it will trigger a SteamManager.OnUser
callback. The SteamUser
component also has its own SteamUser.OnUser
callback.
Names
You can access your name via SteamManager.Name
and that of other users via SteamManager.GetName(ulong)
. On a SteamUser
component, you can use SteamUser.Name
.
Icons
To get an icon, use SteamManager.GetIcon(ref Texture2D, SteamIconSize)
for yourself and SteamManager.GetIcon(ulong, ref Texture2D, SteamIconSize)
for others. You can access the icon of a SteamUser
with SteamUser.Icon
.
If SteamManager.GetIcon(ref Texture2D, SteamIconSize)
or SteamManager.GetIcon(ulong, ref Texture2D, SteamIconSize)
returns a SteamIconStatus
of Requested
, it means we do not yet have the user's icon downloaded. In this case, you need to wait for a SteamManager.OnIcon
callback for the user you want the icon for, and then proceed to call SteamManager.GetIcon(ref Texture2D, SteamIconSize)
or SteamManager.GetIcon(ulong, ref Texture2D, SteamIconSize)
again.
The SteamUser
component will automatically keep its user's icon up to date, invoking the SteamUser.OnIcon
callback whenever it is updated.
State
You can access your online state via SteamManager.State
and that of other users via SteamManager.GetState(ulong)
. On a SteamUser
component, you can use SteamUser.State
.
Relationship
You can access your relationship with a user with SteamManager.GetRelationship(ulong)
. On a SteamUser
component, you can use SteamUser.Relationship
.
Rich Presence
You can get a rich presence entry of yours with SteamManager.GetRichPresence(string)
and for other users with SteamManager.GetRichPresence(ulong, string)
. To get all currently set rich presence, you can use SteamManager.RichPresence
for yourself and SteamManager.GetRichPresence(ulong)
for others.
You can set your rich presence through SteamManager.SetRichPresence(string, string)
and SteamManager.SetRichPresence(IEnumerable<KeyValuePair<string, string>>)
; using NULL
for values will delete said rich presence. You can clear your rich presence with SteamManager.ClearRichPresence()
.
To listen for rich presence updating, use the SteamManager.OnRichPresence
and SteamUser.OnRichPresence
callbacks.
Special Keys
Certain keys serve special purposes for rich presence. Some require configuration on the Steam backend for which you can learn more about in the Steamworks documentation. MPE4S provides helpers to quickly get or set these values.
Connect
The connect
key is used to configure the ability for your friends to join your game through the Steam user interface. MPE4S handles this automatically with respect to lobby visibility, open state, and player capacity, and will prevent you from manually setting it with SteamManager.SetRichPresence(string, string)
and SteamManager.SetRichPresence(IEnumerable<KeyValuePair<string, string>>)
. SteamManager.ClearRichPresence()
will ignore this key.
Grouping
The group
key is used to display you along with other friends you are playing with as being in a group in the Steam friends user interface, with the group_size
key defining the total size of your group to display, consisting of all group members, even non-friends. You can get your values through SteamManager.Group
and SteamManager.GroupSize
, other users using SteamManager.GetGroup(ulong)
and SteamManager.GetGroupSize(ulong)
, and from a SteamUser
component using SteamUser.Group
and SteamUser.GroupSize
.
MPE4S gives you the option to automatically or manually handle grouping by setting SteamManager.AutoGroup
. If SteamManager.AutoGroup
is enabled, it will block you from setting the group
and group_size
rich presence values. Additionally, when SteamManager.AutoGroup
is enabled, SteamManager.ClearRichPresence()
will ignore these keys.
Automatic grouping is perfect for games without teams. If your game is team-based, you may want to utilize manual grouping by disabling SteamManager.AutoGroup
and setting SteamManager.Group
and SteamManager.GroupSize
. For example, simply set SteamManager.GroupSize
to the number of players on your team in the lobby, and set SteamManager.Group
to a unique value composed of the SteamManager.LobbyId
and your team's name such as $"{SteamManager.LobbyId}_red"
if you were on the red team.
Status
The status
will show up when a user clicks on your "view game info" dialog in the Steam friends list. You can get and set it for yourself using SteamManager.Status
and get it for other users with SteamManager.GetStatus(ulong)
.
Display
steam_display
names a rich presence localization token that will be displayed in the viewing user's selected language in the Steam client user interface. This requires configuration on the Steam backend for which you can learn more about in the Steamworks documentation. You can get and set it for yourself using SteamManager.Display
and get it for other users with SteamManager.GetDisplay(ulong)
.
Data
For details on how to get and set member data, see the matchmaking documentation.
Friends
To get all of your friends, use SteamManager.GetFriends(bool)
.