docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class SteamUser

    Purpose: Functions for accessing and manipulating a steam account associated with one client instance

    Inheritance
    object
    SteamUser
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.Steamworks.Interop
    Assembly: Unity.Steamworks.Interop.dll
    Syntax
    public static class SteamUser

    Methods

    AdvertiseGame(CSteamID, uint, ushort)

    set data to be replicated to friends so that they can join your game CSteamID steamIDGameServer - the steamID of the game server, received from the game server by the client uint32 unIPServer, uint16 usPortServer - the IP address of the game server

    Declaration
    public static void AdvertiseGame(CSteamID steamIDGameServer, uint unIPServer, ushort usPortServer)
    Parameters
    Type Name Description
    CSteamID steamIDGameServer

    Passed through to ISteamUser::AdvertiseGame.

    uint unIPServer

    Passed through to ISteamUser::AdvertiseGame.

    ushort usPortServer

    Passed through to ISteamUser::AdvertiseGame.

    BIsBehindNAT()

    returns true if this users looks like they are behind a NAT device. Only valid once the user has connected to steam (i.e a SteamServersConnected_t has been issued) and may not catch all forms of NAT.

    Declaration
    public static bool BIsBehindNAT()
    Returns
    Type Description
    bool

    The value ISteamUser::BIsBehindNAT returns.

    BIsPhoneIdentifying()

    gets whether the users phone number is identifying

    Declaration
    public static bool BIsPhoneIdentifying()
    Returns
    Type Description
    bool

    The value ISteamUser::BIsPhoneIdentifying returns.

    BIsPhoneRequiringVerification()

    gets whether the users phone number is awaiting (re)verification

    Declaration
    public static bool BIsPhoneRequiringVerification()
    Returns
    Type Description
    bool

    The value ISteamUser::BIsPhoneRequiringVerification returns.

    BIsPhoneVerified()

    gets whether the users phone number is verified

    Declaration
    public static bool BIsPhoneVerified()
    Returns
    Type Description
    bool

    The value ISteamUser::BIsPhoneVerified returns.

    BIsTwoFactorEnabled()

    gets whether the user has two factor enabled on their account

    Declaration
    public static bool BIsTwoFactorEnabled()
    Returns
    Type Description
    bool

    The value ISteamUser::BIsTwoFactorEnabled returns.

    BLoggedOn()

    returns true if the Steam client current has a live connection to the Steam servers. If false, it means there is no active connection due to either a networking issue on the local machine, or the Steam server is down/busy. The Steam client will automatically be trying to recreate the connection as often as possible.

    Declaration
    public static bool BLoggedOn()
    Returns
    Type Description
    bool

    The value ISteamUser::BLoggedOn returns.

    BSetDurationControlOnlineState(EDurationControlOnlineState)

    Advise steam china duration control system about the online state of the game. This will prevent offline gameplay time from counting against a user's playtime limits.

    Declaration
    public static bool BSetDurationControlOnlineState(EDurationControlOnlineState eNewState)
    Parameters
    Type Name Description
    EDurationControlOnlineState eNewState

    Passed through to ISteamUser::BSetDurationControlOnlineState.

    Returns
    Type Description
    bool

    The value ISteamUser::BSetDurationControlOnlineState returns.

    BeginAuthSession(byte[], int, CSteamID)

    Authenticate ticket from entity steamID to be sure it is valid and isnt reused Registers for callbacks if the entity goes offline or cancels the ticket ( see ValidateAuthTicketResponse_t callback and EAuthSessionResponse )

    Declaration
    public static EBeginAuthSessionResult BeginAuthSession(byte[] pAuthTicket, int cbAuthTicket, CSteamID steamID)
    Parameters
    Type Name Description
    byte[] pAuthTicket

    Passed through to ISteamUser::BeginAuthSession.

    int cbAuthTicket

    Passed through to ISteamUser::BeginAuthSession.

    CSteamID steamID

    Passed through to ISteamUser::BeginAuthSession.

    Returns
    Type Description
    EBeginAuthSessionResult

    The value ISteamUser::BeginAuthSession returns.

    CancelAuthTicket(HAuthTicket)

    Cancel auth ticket from GetAuthSessionTicket, called when no longer playing game with the entity you gave the ticket to

    Declaration
    public static void CancelAuthTicket(HAuthTicket hAuthTicket)
    Parameters
    Type Name Description
    HAuthTicket hAuthTicket

    Passed through to ISteamUser::CancelAuthTicket.

    DecompressVoice(byte[], uint, byte[], uint, out uint, uint)

    Decodes the compressed voice data returned by GetVoice. The output data is raw single-channel 16-bit PCM audio. The decoder supports any sample rate from 11025 to 48000; see GetVoiceOptimalSampleRate() below for details. If the output buffer is not large enough, then *nBytesWritten will be set to the required buffer size, and k_EVoiceResultBufferTooSmall is returned. It is suggested to start with a 20kb buffer and reallocate as necessary.

    Declaration
    public static EVoiceResult DecompressVoice(byte[] pCompressed, uint cbCompressed, byte[] pDestBuffer, uint cbDestBufferSize, out uint nBytesWritten, uint nDesiredSampleRate)
    Parameters
    Type Name Description
    byte[] pCompressed

    Passed through to ISteamUser::DecompressVoice.

    uint cbCompressed

    Passed through to ISteamUser::DecompressVoice.

    byte[] pDestBuffer

    Passed through to ISteamUser::DecompressVoice.

    uint cbDestBufferSize

    Passed through to ISteamUser::DecompressVoice.

    uint nBytesWritten

    Passed through to ISteamUser::DecompressVoice.

    uint nDesiredSampleRate

    Passed through to ISteamUser::DecompressVoice.

    Returns
    Type Description
    EVoiceResult

    The value ISteamUser::DecompressVoice returns.

    EndAuthSession(CSteamID)

    Stop tracking started by BeginAuthSession - called when no longer playing game with this entity

    Declaration
    public static void EndAuthSession(CSteamID steamID)
    Parameters
    Type Name Description
    CSteamID steamID

    Passed through to ISteamUser::EndAuthSession.

    GetAuthSessionTicket(byte[], int, out uint, ref SteamNetworkingIdentity)

    Retrieve ticket to be sent to the entity who wishes to authenticate you. pcbTicket retrieves the length of the actual ticket. SteamNetworkingIdentity is an optional input parameter to hold the public IP address or SteamID of the entity you are connecting to if an IP address is passed Steam will only allow the ticket to be used by an entity with that IP address if a Steam ID is passed Steam will only allow the ticket to be used by that Steam ID not to be used for "ISteamUserAuth\AuthenticateUserTicket" - it will fail

    Declaration
    public static HAuthTicket GetAuthSessionTicket(byte[] pTicket, int cbMaxTicket, out uint pcbTicket, ref SteamNetworkingIdentity pSteamNetworkingIdentity)
    Parameters
    Type Name Description
    byte[] pTicket

    Passed through to ISteamUser::GetAuthSessionTicket.

    int cbMaxTicket

    Passed through to ISteamUser::GetAuthSessionTicket.

    uint pcbTicket

    Passed through to ISteamUser::GetAuthSessionTicket.

    SteamNetworkingIdentity pSteamNetworkingIdentity

    Passed through to ISteamUser::GetAuthSessionTicket.

    Returns
    Type Description
    HAuthTicket

    The value ISteamUser::GetAuthSessionTicket returns.

    GetAuthTicketForWebApi(string)

    Request a ticket which will be used for webapi "ISteamUserAuth\AuthenticateUserTicket" pchIdentity is an optional input parameter to identify the service the ticket will be sent to the ticket will be returned in callback GetTicketForWebApiResponse_t

    Declaration
    public static HAuthTicket GetAuthTicketForWebApi(string pchIdentity)
    Parameters
    Type Name Description
    string pchIdentity

    Passed through to ISteamUser::GetAuthTicketForWebApi.

    Returns
    Type Description
    HAuthTicket

    The value ISteamUser::GetAuthTicketForWebApi returns.

    GetAvailableVoice(out uint)

    Determine the size of captured audio data that is available from GetVoice. Most applications will only use compressed data and should ignore the other parameters, which exist primarily for backwards compatibility. See comments below for further explanation of "uncompressed" data.

    Declaration
    public static EVoiceResult GetAvailableVoice(out uint pcbCompressed)
    Parameters
    Type Name Description
    uint pcbCompressed

    Passed through to ISteamUser::GetAvailableVoice.

    Returns
    Type Description
    EVoiceResult

    The value ISteamUser::GetAvailableVoice returns.

    GetDurationControl()

    Retrieves anti indulgence / duration control for current user

    Declaration
    public static SteamAPICall_t GetDurationControl()
    Returns
    Type Description
    SteamAPICall_t

    The value ISteamUser::GetDurationControl returns.

    GetDurationControlAsync()

    Async version of GetDurationControl().

    Declaration
    public static Task<DurationControl_t> GetDurationControlAsync()
    Returns
    Type Description
    Task<DurationControl_t>

    The DurationControl_t Steam reports once the call completes.

    GetEncryptedAppTicket(byte[], int, out uint)

    Retrieves a finished ticket. If no ticket is available, or your buffer is too small, returns false. Upon exit, *pcbTicket will be either the size of the ticket copied into your buffer (if true was returned), or the size needed (if false was returned). To determine the proper size of the ticket, you can pass pTicket=NULL and cbMaxTicket=0; if a ticket is available, *pcbTicket will contain the size needed, otherwise it will be zero.

    Declaration
    public static bool GetEncryptedAppTicket(byte[] pTicket, int cbMaxTicket, out uint pcbTicket)
    Parameters
    Type Name Description
    byte[] pTicket

    Passed through to ISteamUser::GetEncryptedAppTicket.

    int cbMaxTicket

    Passed through to ISteamUser::GetEncryptedAppTicket.

    uint pcbTicket

    Passed through to ISteamUser::GetEncryptedAppTicket.

    Returns
    Type Description
    bool

    The value ISteamUser::GetEncryptedAppTicket returns.

    GetGameBadgeLevel(int, bool)

    Trading Card badges data access if you only have one set of cards, the series will be 1 the user has can have two different badges for a series; the regular (max level 5) and the foil (max level 1)

    Declaration
    public static int GetGameBadgeLevel(int nSeries, bool bFoil)
    Parameters
    Type Name Description
    int nSeries

    Passed through to ISteamUser::GetGameBadgeLevel.

    bool bFoil

    Passed through to ISteamUser::GetGameBadgeLevel.

    Returns
    Type Description
    int

    The value ISteamUser::GetGameBadgeLevel returns.

    GetHSteamUser()

    returns the HSteamUser this interface represents this is only used internally by the API, and by a few select interfaces that support multi-user

    Declaration
    public static HSteamUser GetHSteamUser()
    Returns
    Type Description
    HSteamUser

    The value ISteamUser::GetHSteamUser returns.

    GetMarketEligibility()

    Calls the Steamworks ISteamUser::GetMarketEligibility method.

    Declaration
    public static SteamAPICall_t GetMarketEligibility()
    Returns
    Type Description
    SteamAPICall_t

    The value ISteamUser::GetMarketEligibility returns.

    GetMarketEligibilityAsync()

    Async version of GetMarketEligibility().

    Declaration
    public static Task<MarketEligibilityResponse_t> GetMarketEligibilityAsync()
    Returns
    Type Description
    Task<MarketEligibilityResponse_t>

    The MarketEligibilityResponse_t Steam reports once the call completes.

    GetPlayerSteamLevel()

    gets the Steam Level of the user, as shown on their profile

    Declaration
    public static int GetPlayerSteamLevel()
    Returns
    Type Description
    int

    The value ISteamUser::GetPlayerSteamLevel returns.

    GetSteamID()

    returns the CSteamID of the account currently logged into the Steam client a CSteamID is a unique identifier for an account, and used to differentiate users in all parts of the Steamworks API

    Declaration
    public static CSteamID GetSteamID()
    Returns
    Type Description
    CSteamID

    The value ISteamUser::GetSteamID returns.

    GetUserDataFolder(out string, int)

    get the local storage folder for current Steam account to write application data, e.g. save games, configs etc. this will usually be something like "C:\Progam Files\Steam\userdata&lt;SteamID>&lt;AppID>\local"

    Declaration
    public static bool GetUserDataFolder(out string pchBuffer, int cubBuffer)
    Parameters
    Type Name Description
    string pchBuffer

    Receives the string ISteamUser::GetUserDataFolder writes.

    int cubBuffer

    Passed through to ISteamUser::GetUserDataFolder.

    Returns
    Type Description
    bool

    The value ISteamUser::GetUserDataFolder returns.

    GetVoice(bool, byte[], uint, out uint)

    NOTE: "uncompressed" audio is a deprecated feature and should not be used by most applications. It is raw single-channel 16-bit PCM wave data which may have been run through preprocessing filters and/or had silence removed, so the uncompressed audio could have a shorter duration than you expect. There may be no data at all during long periods of silence. Also, fetching uncompressed audio will cause GetVoice to discard any leftover compressed audio, so you must fetch both types at once. Finally, GetAvailableVoice is not precisely accurate when the uncompressed size is requested. So if you really need to use uncompressed audio, you should call GetVoice frequently with two very large (20kb+) output buffers instead of trying to allocate perfectly-sized buffers. But most applications should ignore all of these details and simply leave the "uncompressed" parameters as NULL/zero. Read captured audio data from the microphone buffer. This should be called at least once per frame, and preferably every few milliseconds, to keep the microphone input delay as low as possible. Most applications will only use compressed data and should pass NULL/zero for the "uncompressed" parameters. Compressed data can be transmitted by your application and decoded into raw using the DecompressVoice function below.

    Declaration
    public static EVoiceResult GetVoice(bool bWantCompressed, byte[] pDestBuffer, uint cbDestBufferSize, out uint nBytesWritten)
    Parameters
    Type Name Description
    bool bWantCompressed

    Passed through to ISteamUser::GetVoice.

    byte[] pDestBuffer

    Passed through to ISteamUser::GetVoice.

    uint cbDestBufferSize

    Passed through to ISteamUser::GetVoice.

    uint nBytesWritten

    Passed through to ISteamUser::GetVoice.

    Returns
    Type Description
    EVoiceResult

    The value ISteamUser::GetVoice returns.

    GetVoiceOptimalSampleRate()

    This returns the native sample rate of the Steam voice decompressor; using this sample rate for DecompressVoice will perform the least CPU processing. However, the final audio quality will depend on how well the audio device (and/or your application's audio output SDK) deals with lower sample rates. You may find that you get the best audio output quality when you ignore this function and use the native sample rate of your audio output device, which is usually 48000 or 44100.

    Declaration
    public static uint GetVoiceOptimalSampleRate()
    Returns
    Type Description
    uint

    The value ISteamUser::GetVoiceOptimalSampleRate returns.

    InitiateGameConnection_DEPRECATED(byte[], int, CSteamID, uint, ushort, bool)

    Multiplayer Authentication functions InitiateGameConnection() starts the state machine for authenticating the game client with the game server It is the client portion of a three-way handshake between the client, the game server, and the steam servers Parameters: void *pAuthBlob - a pointer to empty memory that will be filled in with the authentication token. int cbMaxAuthBlob - the number of bytes of allocated memory in pBlob. Should be at least 2048 bytes. CSteamID steamIDGameServer - the steamID of the game server, received from the game server by the client CGameID gameID - the ID of the current game. For games without mods, this is just CGameID( <appID> ) uint32 unIPServer, uint16 usPortServer - the IP address of the game server bool bSecure - whether or not the client thinks that the game server is reporting itself as secure (i.e. VAC is running) return value - returns the number of bytes written to pBlob. If the return is 0, then the buffer passed in was too small, and the call has failed The contents of pBlob should then be sent to the game server, for it to use to complete the authentication process. DEPRECATED! This function will be removed from the SDK in an upcoming version. Please migrate to BeginAuthSession and related functions.

    Declaration
    public static int InitiateGameConnection_DEPRECATED(byte[] pAuthBlob, int cbMaxAuthBlob, CSteamID steamIDGameServer, uint unIPServer, ushort usPortServer, bool bSecure)
    Parameters
    Type Name Description
    byte[] pAuthBlob

    Passed through to ISteamUser::InitiateGameConnection_DEPRECATED.

    int cbMaxAuthBlob

    Passed through to ISteamUser::InitiateGameConnection_DEPRECATED.

    CSteamID steamIDGameServer

    Passed through to ISteamUser::InitiateGameConnection_DEPRECATED.

    uint unIPServer

    Passed through to ISteamUser::InitiateGameConnection_DEPRECATED.

    ushort usPortServer

    Passed through to ISteamUser::InitiateGameConnection_DEPRECATED.

    bool bSecure

    Passed through to ISteamUser::InitiateGameConnection_DEPRECATED.

    Returns
    Type Description
    int

    The value ISteamUser::InitiateGameConnection_DEPRECATED returns.

    RequestEncryptedAppTicket(byte[], int)

    Requests a ticket encrypted with an app specific shared key pDataToInclude, cbDataToInclude will be encrypted into the ticket ( This is asynchronous, you must wait for the ticket to be completed by the server )

    Declaration
    public static SteamAPICall_t RequestEncryptedAppTicket(byte[] pDataToInclude, int cbDataToInclude)
    Parameters
    Type Name Description
    byte[] pDataToInclude

    Passed through to ISteamUser::RequestEncryptedAppTicket.

    int cbDataToInclude

    Passed through to ISteamUser::RequestEncryptedAppTicket.

    Returns
    Type Description
    SteamAPICall_t

    The value ISteamUser::RequestEncryptedAppTicket returns.

    RequestEncryptedAppTicketAsync(byte[], int)

    Async version of RequestEncryptedAppTicket(byte[], int).

    Declaration
    public static Task<EncryptedAppTicketResponse_t> RequestEncryptedAppTicketAsync(byte[] pDataToInclude, int cbDataToInclude)
    Parameters
    Type Name Description
    byte[] pDataToInclude

    Passed through to ISteamUser::RequestEncryptedAppTicket.

    int cbDataToInclude

    Passed through to ISteamUser::RequestEncryptedAppTicket.

    Returns
    Type Description
    Task<EncryptedAppTicketResponse_t>

    The EncryptedAppTicketResponse_t Steam reports once the call completes.

    RequestStoreAuthURL(string)

    Requests a URL which authenticates an in-game browser for store check-out, and then redirects to the specified URL. As long as the in-game browser accepts and handles session cookies, Steam microtransaction checkout pages will automatically recognize the user instead of presenting a login page. The result of this API call will be a StoreAuthURLResponse_t callback. NOTE: The URL has a very short lifetime to prevent history-snooping attacks, so you should only call this API when you are about to launch the browser, or else immediately navigate to the result URL using a hidden browser window. NOTE 2: The resulting authorization cookie has an expiration time of one day, so it would be a good idea to request and visit a new auth URL every 12 hours.

    Declaration
    public static SteamAPICall_t RequestStoreAuthURL(string pchRedirectURL)
    Parameters
    Type Name Description
    string pchRedirectURL

    Passed through to ISteamUser::RequestStoreAuthURL.

    Returns
    Type Description
    SteamAPICall_t

    The value ISteamUser::RequestStoreAuthURL returns.

    RequestStoreAuthURLAsync(string)

    Async version of RequestStoreAuthURL(string).

    Declaration
    public static Task<StoreAuthURLResponse_t> RequestStoreAuthURLAsync(string pchRedirectURL)
    Parameters
    Type Name Description
    string pchRedirectURL

    Passed through to ISteamUser::RequestStoreAuthURL.

    Returns
    Type Description
    Task<StoreAuthURLResponse_t>

    The StoreAuthURLResponse_t Steam reports once the call completes.

    StartVoiceRecording()

    Starts voice recording. Once started, use GetVoice() to get the data

    Declaration
    public static void StartVoiceRecording()

    StopVoiceRecording()

    Stops voice recording. Because people often release push-to-talk keys early, the system will keep recording for a little bit after this function is called. GetVoice() should continue to be called until it returns k_eVoiceResultNotRecording

    Declaration
    public static void StopVoiceRecording()

    TerminateGameConnection_DEPRECATED(uint, ushort)

    notify of disconnect needs to occur when the game client leaves the specified game server, needs to match with the InitiateGameConnection() call DEPRECATED! This function will be removed from the SDK in an upcoming version. Please migrate to BeginAuthSession and related functions.

    Declaration
    public static void TerminateGameConnection_DEPRECATED(uint unIPServer, ushort usPortServer)
    Parameters
    Type Name Description
    uint unIPServer

    Passed through to ISteamUser::TerminateGameConnection_DEPRECATED.

    ushort usPortServer

    Passed through to ISteamUser::TerminateGameConnection_DEPRECATED.

    TrackAppUsageEvent(CGameID, int, string)

    Legacy functions used by only a few games to track usage events

    Declaration
    public static void TrackAppUsageEvent(CGameID gameID, int eAppUsageEvent, string pchExtraInfo = "")
    Parameters
    Type Name Description
    CGameID gameID

    Passed through to ISteamUser::TrackAppUsageEvent.

    int eAppUsageEvent

    Passed through to ISteamUser::TrackAppUsageEvent.

    string pchExtraInfo

    Passed through to ISteamUser::TrackAppUsageEvent.

    UserHasLicenseForApp(CSteamID, AppId_t)

    After receiving a user's authentication data, and passing it to BeginAuthSession, use this function to determine if the user owns downloadable content specified by the provided AppID.

    Declaration
    public static EUserHasLicenseForAppResult UserHasLicenseForApp(CSteamID steamID, AppId_t appID)
    Parameters
    Type Name Description
    CSteamID steamID

    Passed through to ISteamUser::UserHasLicenseForApp.

    AppId_t appID

    Passed through to ISteamUser::UserHasLicenseForApp.

    Returns
    Type Description
    EUserHasLicenseForAppResult

    The value ISteamUser::UserHasLicenseForApp returns.

    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)