Class SteamUtils
Purpose: interface to user independent utility functions
Inherited Members
Namespace: Unity.Steamworks.Interop
Assembly: Unity.Steamworks.Interop.dll
Syntax
public static class SteamUtils
Methods
BOverlayNeedsPresent()
Normally this call is unneeded if your game has a constantly running frame loop that calls the D3D Present API, or OGL SwapBuffers API every frame. However, if you have a game that only refreshes the screen on an event driven basis then that can break the overlay, as it uses your Present/SwapBuffers calls to drive it's internal frame loop and it may also need to Present() to the screen any time an even needing a notification happens or when the overlay is brought up over the game by a user. You can use this API to ask the overlay if it currently need a present in that case, and then you can check for this periodically (roughly 33hz is desirable) and make sure you refresh the screen with Present or SwapBuffers to allow the overlay to do it's work.
Declaration
public static bool BOverlayNeedsPresent()
Returns
| Type | Description |
|---|---|
| bool | The value |
CheckFileSignature(string)
Asynchronous call to check if an executable file has been signed using the public key set on the signing tab of the partner site, for example to refuse to load modified executable files. The result is returned in CheckFileSignature_t. k_ECheckFileSignatureNoSignaturesFoundForThisApp - This app has not been configured on the signing tab of the partner site to enable this function. k_ECheckFileSignatureNoSignaturesFoundForThisFile - This file is not listed on the signing tab for the partner site. k_ECheckFileSignatureFileNotFound - The file does not exist on disk. k_ECheckFileSignatureInvalidSignature - The file exists, and the signing tab has been set for this file, but the file is either not signed or the signature does not match. k_ECheckFileSignatureValidSignature - The file is signed and the signature is valid.
Declaration
public static SteamAPICall_t CheckFileSignature(string szFileName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | szFileName | Passed through to |
Returns
| Type | Description |
|---|---|
| SteamAPICall_t | The value |
CheckFileSignatureAsync(string)
Async version of CheckFileSignature(string).
Declaration
public static Task<CheckFileSignature_t> CheckFileSignatureAsync(string szFileName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | szFileName | Passed through to |
Returns
| Type | Description |
|---|---|
| Task<CheckFileSignature_t> | The CheckFileSignature_t Steam reports once the call completes. |
DismissFloatingGamepadTextInput()
Dismisses the floating keyboard.
Declaration
public static bool DismissFloatingGamepadTextInput()
Returns
| Type | Description |
|---|---|
| bool | The value |
DismissGamepadTextInput()
Dismisses the full-screen text input dialog.
Declaration
public static bool DismissGamepadTextInput()
Returns
| Type | Description |
|---|---|
| bool | The value |
FilterText(ETextFilteringContext, CSteamID, string, out string, uint)
Filters the provided input message and places the filtered result into pchOutFilteredText, using legally required filtering and additional filtering based on the context and user settings eContext is the type of content in the input string sourceSteamID is the Steam ID that is the source of the input string (e.g. the player with the name, or who said the chat text) pchInputText is the input string that should be filtered, which can be ASCII or UTF-8 pchOutFilteredText is where the output will be placed, even if no filtering is performed nByteSizeOutFilteredText is the size (in bytes) of pchOutFilteredText, should be at least strlen(pchInputText)+1 Returns the number of characters (not bytes) filtered
Declaration
public static int FilterText(ETextFilteringContext eContext, CSteamID sourceSteamID, string pchInputMessage, out string pchOutFilteredText, uint nByteSizeOutFilteredText)
Parameters
| Type | Name | Description |
|---|---|---|
| ETextFilteringContext | eContext | Passed through to |
| CSteamID | sourceSteamID | Passed through to |
| string | pchInputMessage | Passed through to |
| string | pchOutFilteredText | Receives the string |
| uint | nByteSizeOutFilteredText | Passed through to |
Returns
| Type | Description |
|---|---|
| int | The value |
GetAPICallFailureReason(SteamAPICall_t)
Calls the Steamworks ISteamUtils::GetAPICallFailureReason method.
Declaration
public static ESteamAPICallFailure GetAPICallFailureReason(SteamAPICall_t hSteamAPICall)
Parameters
| Type | Name | Description |
|---|---|---|
| SteamAPICall_t | hSteamAPICall | Passed through to |
Returns
| Type | Description |
|---|---|
| ESteamAPICallFailure | The value |
GetAPICallResult(SteamAPICall_t, IntPtr, int, int, out bool)
Calls the Steamworks ISteamUtils::GetAPICallResult method.
Declaration
public static bool GetAPICallResult(SteamAPICall_t hSteamAPICall, IntPtr pCallback, int cubCallback, int iCallbackExpected, out bool pbFailed)
Parameters
| Type | Name | Description |
|---|---|---|
| SteamAPICall_t | hSteamAPICall | Passed through to |
| IntPtr | pCallback | Passed through to |
| int | cubCallback | Passed through to |
| int | iCallbackExpected | Passed through to |
| bool | pbFailed | Passed through to |
Returns
| Type | Description |
|---|---|
| bool | The value |
GetAppID()
returns the appID of the current process
Declaration
public static AppId_t GetAppID()
Returns
| Type | Description |
|---|---|
| AppId_t | The value |
GetConnectedUniverse()
the universe this client is connecting to
Declaration
public static EUniverse GetConnectedUniverse()
Returns
| Type | Description |
|---|---|
| EUniverse | The value |
GetCurrentBatteryPower()
return the amount of battery power left in the current system in % [0..100], 255 for being on AC power
Declaration
public static byte GetCurrentBatteryPower()
Returns
| Type | Description |
|---|---|
| byte | The value |
GetEnteredGamepadTextInput(out string, uint)
Calls the Steamworks ISteamUtils::GetEnteredGamepadTextInput method.
Declaration
public static bool GetEnteredGamepadTextInput(out string pchText, uint cchText)
Parameters
| Type | Name | Description |
|---|---|---|
| string | pchText | Receives the string |
| uint | cchText | Passed through to |
Returns
| Type | Description |
|---|---|
| bool | The value |
GetEnteredGamepadTextLength()
Returns previously entered text & length
Declaration
public static uint GetEnteredGamepadTextLength()
Returns
| Type | Description |
|---|---|
| uint | The value |
GetIPCCallCount()
returns the number of IPC calls made since the last time this function was called Used for perf debugging so you can understand how many IPC calls your game makes per frame Every IPC call is at minimum a thread context switch if not a process one so you want to rate control how often you do them.
Declaration
public static uint GetIPCCallCount()
Returns
| Type | Description |
|---|---|
| uint | The value |
GetIPCountry()
returns the 2 digit ISO 3166-1-alpha-2 format country code this client is running in (as looked up via an IP-to-location database) e.g "US" or "UK".
Declaration
public static string GetIPCountry()
Returns
| Type | Description |
|---|---|
| string | The value |
GetIPv6ConnectivityState(ESteamIPv6ConnectivityProtocol)
Return what we believe your current ipv6 connectivity to "the internet" is on the specified protocol. This does NOT tell you if the Steam client is currently connected to Steam via ipv6.
Declaration
public static ESteamIPv6ConnectivityState GetIPv6ConnectivityState(ESteamIPv6ConnectivityProtocol eProtocol)
Parameters
| Type | Name | Description |
|---|---|---|
| ESteamIPv6ConnectivityProtocol | eProtocol | Passed through to |
Returns
| Type | Description |
|---|---|
| ESteamIPv6ConnectivityState | The value |
GetImageRGBA(int, byte[], int)
returns true if the image exists, and the buffer was successfully filled out results are returned in RGBA format the destination buffer size should be 4 * height * width * sizeof(char)
Declaration
public static bool GetImageRGBA(int iImage, byte[] pubDest, int nDestBufferSize)
Parameters
| Type | Name | Description |
|---|---|---|
| int | iImage | Passed through to |
| byte[] | pubDest | Passed through to |
| int | nDestBufferSize | Passed through to |
Returns
| Type | Description |
|---|---|
| bool | The value |
GetImageSize(int, out uint, out uint)
returns true if the image exists, and valid sizes were filled out
Declaration
public static bool GetImageSize(int iImage, out uint pnWidth, out uint pnHeight)
Parameters
| Type | Name | Description |
|---|---|---|
| int | iImage | Passed through to |
| uint | pnWidth | Passed through to |
| uint | pnHeight | Passed through to |
Returns
| Type | Description |
|---|---|
| bool | The value |
GetSecondsSinceAppActive()
return the number of seconds since the user
Declaration
public static uint GetSecondsSinceAppActive()
Returns
| Type | Description |
|---|---|
| uint | The value |
GetSecondsSinceComputerActive()
Calls the Steamworks ISteamUtils::GetSecondsSinceComputerActive method.
Declaration
public static uint GetSecondsSinceComputerActive()
Returns
| Type | Description |
|---|---|
| uint | The value |
GetServerRealTime()
Steam server time. Number of seconds since January 1, 1970, GMT (i.e unix time)
Declaration
public static uint GetServerRealTime()
Returns
| Type | Description |
|---|---|
| uint | The value |
GetSteamHardwareDefaultConfig()
Use this method to help choose default game settings (video and other) that you have tuned for specific Steam hardware. It also enables changing your default game settings on future Steam hardware without needing to recompile your game. This method returns an ESteamHardwareDefaultConfig, which has two categories of values:
- Machine specific values: Map each of these values to a setting configuration tuned for that device.
- General values (low, medium, high, max): Map these values to one of your game's user selectable setting presets. If your game has less than 4 presets, it is expected that multiple values might map to the same preset. For example, a game with 3 presets might map high and max to the game's 'high' user preset. For games that only have 1 preset and run great on any device, low, medium, high and max might all be mapped to that single preset. By default, this method will return a value corresponding to the device type returned by ISteamUtils::IsRunningOnSteamHardware(), such as returning k_ESteamHardwareDefaultConfigSteamDeck when running on a Steam Deck. It may also return a configuration value for 3rd party hardware that has similar performance characteristics to Steam hardware, such as returning k_ESteamHardwareDefaultConfigSteamDeck when running on a Legion Go S. You can also change what value the Steam Client returns per device through the Steamworks Partner Site. This allows you to customize the default configuration used on future Steam hardware without recompiling your game. For example, if your game runs well on Steam Machine using your 'high' user preset, but was released before that device became available, you could configure this method to return k_ESteamHardwareDefaultConfigHigh when run on those devices. Similarly if your game was released before Steam Frame, you could configure this method to return k_ESteamHardwareDefaultConfigSteamDeck so that when your game is run in 2d mode, it uses your tuned Steam Deck presets. The following example covers a common approach to choosing default settings when running on Steam hardware:
- Call GetSteamHardwareDefaultConfig()
- If the returned value is for hardware that you have a known configuration for, use a tuned matching configuration
- If the returned value is low, medium, high or max, use a matching user preset
- If the returned value had no match, fall back to your default setting heuristics
Declaration
public static ESteamHardwareDefaultConfig GetSteamHardwareDefaultConfig()
Returns
| Type | Description |
|---|---|
| ESteamHardwareDefaultConfig | The value |
GetSteamUILanguage()
returns the language the steam client is running in, you probably want ISteamApps::GetCurrentGameLanguage instead, this is for very special usage cases
Declaration
public static string GetSteamUILanguage()
Returns
| Type | Description |
|---|---|
| string | The value |
InitFilterText(uint)
Initializes text filtering, loading dictionaries for the language the game is running in. unFilterOptions are reserved for future use and should be set to 0 Returns false if filtering is unavailable for the game's language, in which case FilterText() will act as a passthrough. Users can customize the text filter behavior in their Steam Account preferences: https://store.steampowered.com/account/preferences#CommunityContentPreferences
Declaration
public static bool InitFilterText(uint unFilterOptions = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| uint | unFilterOptions | Passed through to |
Returns
| Type | Description |
|---|---|
| bool | The value |
IsAPICallCompleted(SteamAPICall_t, out bool)
API asynchronous call results can be used directly, but more commonly used via the callback dispatch API (see steam_api.h)
Declaration
public static bool IsAPICallCompleted(SteamAPICall_t hSteamAPICall, out bool pbFailed)
Parameters
| Type | Name | Description |
|---|---|---|
| SteamAPICall_t | hSteamAPICall | Passed through to |
| bool | pbFailed | Passed through to |
Returns
| Type | Description |
|---|---|
| bool | The value |
IsOverlayEnabled()
Returns true if the overlay is running & the user can access it. The overlay process could take a few seconds to start & hook the game process, so this function will initially return false while the overlay is loading.
Declaration
public static bool IsOverlayEnabled()
Returns
| Type | Description |
|---|---|
| bool | The value |
IsRunningOnSteamHardware()
Returns if your process is running on a Steam Deck, Machine, Frame or other hardware. This method is intended to be used for usage analytics, support, diagnostic and other non-functional decisions. If your process needs to make a feature or device capability related decision, the Steamworks SDK exposes a set of other methods. Using one of these alternate methods will enable your game to run correctly on future versions of Steam hardware where this method would return a hardware type not present in old SDK versions. Some alternate methods include:
- ISteamUtils::GetSteamHardwareDefaultConfig()
- ISteamUtils::IsSteamInBigPictureMode()
- ISteamUtils::IsRunningUnderProton()
- ISteamUtils::IsSteamRunningInVR()
- ISteamUtils::GetCurrentBatteryPower()
- ISteamUtils::GetConnectedControllers()
Declaration
public static ESteamHardwareType IsRunningOnSteamHardware()
Returns
| Type | Description |
|---|---|
| ESteamHardwareType | The value |
IsRunningUnderProton()
Returns true if running under the Proton compatibility layer
Declaration
public static bool IsRunningUnderProton()
Returns
| Type | Description |
|---|---|
| bool | The value |
IsSteamChinaLauncher()
Returns whether this steam client is a Steam China specific client, vs the global client.
Declaration
public static bool IsSteamChinaLauncher()
Returns
| Type | Description |
|---|---|
| bool | The value |
IsSteamInBigPictureMode()
Returns true if Steam & the Steam Overlay are running in Big Picture mode, where the user is most likely using a gamepad to control the device in a living room like setting or at an increased viewing distance from the TV. Games must be launched through the Steam client to enable the Big Picture overlay. During development, a game can be added as a non-steam game to the developers library to test this feature.
Declaration
public static bool IsSteamInBigPictureMode()
Returns
| Type | Description |
|---|---|
| bool | The value |
IsSteamRunningInVR()
returns true if Steam itself is running in VR mode
Declaration
public static bool IsSteamRunningInVR()
Returns
| Type | Description |
|---|---|
| bool | The value |
IsVRHeadsetStreamingEnabled()
Returns true if the HMD content will be streamed via Steam Remote Play
Declaration
public static bool IsVRHeadsetStreamingEnabled()
Returns
| Type | Description |
|---|---|
| bool | The value |
SetGameLauncherMode(bool)
In game launchers that don't have controller support you can call this to have Steam Input translate the controller input into mouse/kb to navigate the launcher
Declaration
public static void SetGameLauncherMode(bool bLauncherMode)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | bLauncherMode | Passed through to |
SetOverlayNotificationInset(int, int)
Sets the inset of the overlay notification from the corner specified by SetOverlayNotificationPosition.
Declaration
public static void SetOverlayNotificationInset(int nHorizontalInset, int nVerticalInset)
Parameters
| Type | Name | Description |
|---|---|---|
| int | nHorizontalInset | Passed through to |
| int | nVerticalInset | Passed through to |
SetOverlayNotificationPosition(ENotificationPosition)
Sets the position where the overlay instance for the currently calling game should show notifications. This position is per-game and if this function is called from outside of a game context it will do nothing.
Declaration
public static void SetOverlayNotificationPosition(ENotificationPosition eNotificationPosition)
Parameters
| Type | Name | Description |
|---|---|---|
| ENotificationPosition | eNotificationPosition | Passed through to |
SetVRHeadsetStreamingEnabled(bool)
Set whether the HMD content will be streamed via Steam Remote Play If this is set to true, then the scene in the HMD headset will be streamed, and remote input will not be allowed. If this is set to false, then the application window will be streamed instead, and remote input will be allowed. The default is true unless "VRHeadsetStreaming" "0" is in the extended appinfo for a game. (this is useful for games that have asymmetric multiplayer gameplay)
Declaration
public static void SetVRHeadsetStreamingEnabled(bool bEnabled)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | bEnabled | Passed through to |
SetWarningMessageHook(SteamAPIWarningMessageHook_t)
API warning handling 'int' is the severity; 0 for msg, 1 for warning 'const char *' is the text of the message callbacks will occur directly after the API function is called that generated the warning or message
Declaration
public static void SetWarningMessageHook(SteamAPIWarningMessageHook_t pFunction)
Parameters
| Type | Name | Description |
|---|---|---|
| SteamAPIWarningMessageHook_t | pFunction | Passed through to |
ShowFloatingGamepadTextInput(EFloatingGamepadTextInputMode, int, int, int, int)
Opens a floating keyboard over the game content and sends OS keyboard keys directly to the game. The text field position is specified in pixels relative the origin of the game window and is used to position the floating keyboard in a way that doesn't cover the text field
Declaration
public static bool ShowFloatingGamepadTextInput(EFloatingGamepadTextInputMode eKeyboardMode, int nTextFieldXPosition, int nTextFieldYPosition, int nTextFieldWidth, int nTextFieldHeight)
Parameters
| Type | Name | Description |
|---|---|---|
| EFloatingGamepadTextInputMode | eKeyboardMode | Passed through to |
| int | nTextFieldXPosition | Passed through to |
| int | nTextFieldYPosition | Passed through to |
| int | nTextFieldWidth | Passed through to |
| int | nTextFieldHeight | Passed through to |
Returns
| Type | Description |
|---|---|
| bool | The value |
ShowGamepadTextInput(EGamepadTextInputMode, EGamepadTextInputLineMode, string, uint, string)
Activates the full-screen text input dialog which takes a initial text string and returns the text the user has typed
Declaration
public static bool ShowGamepadTextInput(EGamepadTextInputMode eInputMode, EGamepadTextInputLineMode eLineInputMode, string pchDescription, uint unCharMax, string pchExistingText)
Parameters
| Type | Name | Description |
|---|---|---|
| EGamepadTextInputMode | eInputMode | Passed through to |
| EGamepadTextInputLineMode | eLineInputMode | Passed through to |
| string | pchDescription | Passed through to |
| uint | unCharMax | Passed through to |
| string | pchExistingText | Passed through to |
Returns
| Type | Description |
|---|---|
| bool | The value |
StartVRDashboard()
ask SteamUI to create and render its OpenVR dashboard
Declaration
public static void StartVRDashboard()