Class SDK
Main part of Pley SDK, handles the basic like Initialization, logging, etc...
Inheritance
Namespace: Pley
Assembly: Pley.dll
Syntax
public class SDK : object
Properties
IsGameFocused
Returns whether or not the game is currently in focus. Not being in any other tab or popup from Payments or invite link.
Declaration
public static bool IsGameFocused { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsInitialized
Checks whether or not SDK is initialized.
Declaration
public static bool IsInitialized { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
LogEnabled
Enables or disables the logging by the SDK
Declaration
public static bool LogEnabled { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
LogLevel
Set/Get the minimum log level for the SDK.
Declaration
public static PleyLogLevel LogLevel { get; set; }
Property Value
| Type | Description |
|---|---|
| PleyLogLevel |
Methods
CrashGame(String)
Simple and short method to force a crash on Pley.
Declaration
public static PleyResult CrashGame(string errorMessage = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | errorMessage |
Returns
| Type | Description |
|---|---|
| PleyResult |
ExitGame()
Exit method to close the game and return to the main page of Pley. This sadly, won't trigger OnApplicationQuit as Unity currently does not support it! https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationQuit.html
Declaration
public static PleyResult ExitGame()
Returns
| Type | Description |
|---|---|
| PleyResult | Whether it was able to quit the game. |
Finalize()
Declaration
protected void Finalize()
GetGameArguments()
Retrieves the game arguments from an invite link, notification or something else to provide some extra functionalities.
Declaration
public static GameArgument[] GetGameArguments()
Returns
| Type | Description |
|---|---|
| GameArgument[] | Returns an array of the game arguments. |
GetGameArguments(out GameArgument[])
Retrieves the game arguments from an invite link, notification or something else to provide some extra functionalities.
Declaration
public static PleyResult GetGameArguments(out GameArgument[] gameArguments)
Parameters
| Type | Name | Description |
|---|---|---|
| GameArgument[] | gameArguments |
Returns
| Type | Description |
|---|---|
| PleyResult | Whether it succeeded or failed to retrieve the game arguments. |
GetPlayableLocation()
Get the current location where the game is running Some possible locations are "pley", "game-manager", "crazy-games" or "discord"
Declaration
public static string GetPlayableLocation()
Returns
| Type | Description |
|---|---|
| System.String | Returns the location where the game has been started. |
GetPlayableLocation(out String)
Get the current location where the game is running Some possible locations are "pley", "game-manager", "crazy-games" or "discord"
Declaration
public static PleyResult GetPlayableLocation(out string location)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | location | Returns the location where the game has been started. |
Returns
| Type | Description |
|---|---|
| PleyResult | Returns whether succeeded or not to retrieve the location. |
GetStackTrace()
Declaration
public static string GetStackTrace()
Returns
| Type | Description |
|---|---|
| System.String |
GetStackTrace(out String)
Declaration
public static PleyResult GetStackTrace(out string stackTrace)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | stackTrace |
Returns
| Type | Description |
|---|---|
| PleyResult |
InitializeAsync()
Initializes Pley SDK
Declaration
public static async Task<PleyResult> InitializeAsync()
Returns
| Type | Description |
|---|---|
| Task<PleyResult> | Possible errors are the following: SdkAlreadyCreated, SdkAlreadyInitialized, InvalidArguments |
RestartGame()
Simple and short method to force a restart on Pley.
Declaration
public static PleyResult RestartGame()
Returns
| Type | Description |
|---|---|
| PleyResult |
SetSupportDialogCustomFields((String, String)[])
Adds the passed fields to the support dialog. This can be used if you want users to be able to supply your support team with extra info.
Declaration
public static PleyResult SetSupportDialogCustomFields((string, string)[] fields)
Parameters
| Type | Name | Description |
|---|---|---|
| System.ValueTuple<System.String, System.String>[] | fields | List of tuples. The first item defines the custom field label. The second item defines the custom field value |
Returns
| Type | Description |
|---|---|
| PleyResult | Whether it was possible to set the support dialog custom fields |
Remarks
Calling this method will replace the previous fields with the new ones.
Examples
For example, if you have your own user IDs, you might want users to be able to communicate that when talking to your support.
var setSupportDialogCustomFieldsResult = SDK.SetSupportDialogCustomFields(new[] {
("Own user ID", "deadbeef-a114ebeef-b043beef"),
});
ShowControlsMenu()
Declaration
public static PleyResult ShowControlsMenu()
Returns
| Type | Description |
|---|---|
| PleyResult |
ShowCookieConsent()
Declaration
public static PleyResult ShowCookieConsent()
Returns
| Type | Description |
|---|---|
| PleyResult |
ShowSaveBookmarkPrompt()
Show a prompt which guides the user to bookmark the games URL
Declaration
public static PleyResult ShowSaveBookmarkPrompt()
Returns
| Type | Description |
|---|---|
| PleyResult | Whether it was possible to show the save bookmark prompt |
ShowSupportWindow()
Declaration
public static PleyResult ShowSupportWindow()
Returns
| Type | Description |
|---|---|
| PleyResult |
Events
OnFocusChanged
Callback for when the User changes focus from the game or comes back.
Declaration
public static event SDK.GameFocusedChangedCallback OnFocusChanged
Event Type
| Type | Description |
|---|---|
| SDK.GameFocusedChangedCallback |
OnGamePause
Callback for when a pause game request is received
Declaration
public static event SDK.GamePauseRequestCallback OnGamePause
Event Type
| Type | Description |
|---|---|
| SDK.GamePauseRequestCallback |
OnGameUnpause
Callback for when a unpause game request is received
Declaration
public static event SDK.GameUnpauseRequestCallback OnGameUnpause
Event Type
| Type | Description |
|---|---|
| SDK.GameUnpauseRequestCallback |
OnInitialized
Callback when SDK is initialized, this also will call the subscribing method if SDK already is initialized.
Declaration
public static event SDK.InitializedCallback OnInitialized
Event Type
| Type | Description |
|---|---|
| SDK.InitializedCallback |
OnLogReceived
Callback whenever a log is being called from within SDK
Declaration
public static event SDK.LogReceivedCallback OnLogReceived
Event Type
| Type | Description |
|---|---|
| SDK.LogReceivedCallback |