Class SDK
Main part of Trail SDK, handles the basic like Initialization, logging, etc...
Inheritance
Namespace: Trail
Assembly: Trail.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 LogLevel LogLevel { get; set; }
Property Value
Type | Description |
---|---|
LogLevel |
Methods
AddExtraGameLoadTask()
This will block any call to report game loaded until "FinishGameLoadTask" gets called.
Declaration
public static void AddExtraGameLoadTask()
CrashGame(String)
Simple and short method to force a crash on Trail.
Declaration
public static Result CrashGame(string errorMessage = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | errorMessage |
Returns
Type | Description |
---|---|
Result |
ExecuteJS(String)
Execute javascript This method is obsolete. Use the feature of SDK.SendMessageToContainer instead.
Declaration
public static Result ExecuteJS(string script)
Parameters
Type | Name | Description |
---|---|---|
System.String | script | The javascript that should be executed. |
Returns
Type | Description |
---|---|
Result | Whether it was possible to execute the javascript. |
ExitGame()
Exit method to close the game and return to the main page of Trail. This sadly won't trigger OnApplicationQuit as Unity currently do not support it! https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationQuit.html
Declaration
public static Result ExitGame()
Returns
Type | Description |
---|---|
Result | Whether it was able to quit the game. |
Finalize()
Declaration
protected void Finalize()
FinishGameLoadTask()
This will call game loaded to Trail to remove the loading screen. This can further be blocked by Adding Extra tasks to be finished using SDK.AddExtraGameLoadTask()
Declaration
public static Result FinishGameLoadTask()
Returns
Type | Description |
---|---|
Result |
GetStartupArgs()
Retrives the startup arguments from an invite link, notification or something else to provide some extra functionalities.
Declaration
public static SDK.StartupArg[] GetStartupArgs()
Returns
Type | Description |
---|---|
SDK.StartupArg[] | Returns an array of the startup arguments. |
GetStartupArgs(out SDK.StartupArg[])
Retrives the startup arguments from an invite link, notification or something else to provide some extra functionalities.
Declaration
public static Result GetStartupArgs(out SDK.StartupArg[] startupArgs)
Parameters
Type | Name | Description |
---|---|---|
SDK.StartupArg[] | startupArgs |
Returns
Type | Description |
---|---|
Result | Whether it succeeded or failed to retrive the Startup Arguments. |
Init()
Initializes Trail SDK with the Default Dev Server Settings.
Declaration
public static Result Init()
Returns
Type | Description |
---|---|
Result |
Init(String)
Initializes Trail SDK with custom dev host address. Example: 127.0.0.1:23000
Declaration
public static Result Init(string devHost)
Parameters
Type | Name | Description |
---|---|---|
System.String | devHost | The address Trail SDK should connect to if running from Editor. |
Returns
Type | Description |
---|---|
Result | Whether creating the SDK worked. The result of Initialization get's provided in Initialize Callback |
RemoveContainerMessageListener(String, SDK.ContainerMessageCallback)
Remove a listener for a specific message from the container
Declaration
public static void RemoveContainerMessageListener(string messageName, SDK.ContainerMessageCallback callback)
Parameters
Type | Name | Description |
---|---|---|
System.String | messageName | The name of the message |
SDK.ContainerMessageCallback | callback | The callback to remove |
SendMessageToContainer(String, Object)
Send a message with a payload to the container
Declaration
public static Result SendMessageToContainer(string messageName, object payload = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | messageName | The name of the message |
System.Object | payload | The payload |
Returns
Type | Description |
---|---|
Result | Whether the message was successfully sent to the container |
SetContainerMessageListener(String, SDK.ContainerMessageCallback)
Set a listener for a specific message from the container
Declaration
public static void SetContainerMessageListener(string messageName, SDK.ContainerMessageCallback callback)
Parameters
Type | Name | Description |
---|---|---|
System.String | messageName | The name of the message |
SDK.ContainerMessageCallback | callback | The callback to be invoked when receiving a message |
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 Result 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 |
---|---|
Result | 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"),
});
SetSupportInfos((String, String)[])
This method is obsolete. Use SDK.SetSupportDialogCustomFields instead.
Declaration
public static Result SetSupportInfos((string, string)[] fields)
Parameters
Type | Name | Description |
---|---|---|
System.ValueTuple<System.String, System.String>[] | fields |
Returns
Type | Description |
---|---|
Result |
ShowSaveBookmarkPrompt()
Show a prompt which guides the user to bookmark the games URL
Declaration
public static Result ShowSaveBookmarkPrompt()
Returns
Type | Description |
---|---|
Result | Whether it was possible to show the save bookmark prompt |
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 |
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 |