Show / Hide Table of Contents

Class PlayURPlugin

Container singleton class containing state information and functions for interacting with the platform. An instance of this class exists within the PlayURLogin scene. It is auto-generated and you shouldn't need to modify it.

Inheritance
object
Object
Component
Behaviour
MonoBehaviour
UnitySingleton<PlayURPlugin>
UnitySingletonPersistent<PlayURPlugin>
PlayURPlugin
Namespace: PlayUR
Assembly: PlayUR.dll
Syntax
public class PlayURPlugin : UnitySingletonPersistent<PlayURPlugin>

Fields

| Improve this Doc View Source

DASHBOARD_URL

The base url of the dashboard, used for user-facing links. Should point to the "api" sub-directory on the server.

Declaration
public const string DASHBOARD_URL = "https://playur.io/dashboard.php#/"
Field Value
Type Description
string
| Improve this Doc View Source

MTURK_API_ENDPOINT

Declaration
public const string MTURK_API_ENDPOINT = "MTurkCompletion"
Field Value
Type Description
string
| Improve this Doc View Source

MTURK_URL_PARAM

Declaration
public const string MTURK_URL_PARAM = "mTurkID"
Field Value
Type Description
string
| Improve this Doc View Source

MTURK_URL_PARAM_ALT

Declaration
public const string MTURK_URL_PARAM_ALT = "mTurk"
Field Value
Type Description
string
| Improve this Doc View Source

OnReady

Event called when IsReady becomes true. If a new listener is added when the plugin is already ready, the code will be executed immediately.

Declaration
public PlayURReadyEvent OnReady
Field Value
Type Description
PlayURReadyEvent
| Improve this Doc View Source

PERSIST_KEY_PREFIX

The prefix to use for all stored client-side PlayerPrefs information. Used to avoid clashes with user-defined PlayerPrefs.

Declaration
public const string PERSIST_KEY_PREFIX = "PlayUR_"
Field Value
Type Description
string
| Improve this Doc View Source

SERVER_URL

The base url of the server instance through which all Rest requests will go. Should point to the "api" sub-directory on the server.

Declaration
public const string SERVER_URL = "https://playur.io/api/"
Field Value
Type Description
string
| Improve this Doc View Source

browserInfo

Stores browser name and version number. Only valid for WebGL builds. See WebGLLogin(string) and StartSession().

Declaration
public static string browserInfo
Field Value
Type Description
string
| Improve this Doc View Source

configuration

Declaration
protected Configuration configuration
Field Value
Type Description
Configuration
| Improve this Doc View Source

didRequestExperiment

Declaration
[NonSerialized]
public bool didRequestExperiment
Field Value
Type Description
bool
| Improve this Doc View Source

didRequestExperimentGroup

Declaration
[NonSerialized]
public bool didRequestExperimentGroup
Field Value
Type Description
bool
| Improve this Doc View Source

didRequestExperimentOrExperimentGroupFromLoginWindow

Declaration
[NonSerialized]
public bool didRequestExperimentOrExperimentGroupFromLoginWindow
Field Value
Type Description
bool
| Improve this Doc View Source

mTurkFromStandaloneLoginInfo

Declaration
protected string mTurkFromStandaloneLoginInfo
Field Value
Type Description
string
| Improve this Doc View Source

requestedExperiment

Declaration
[NonSerialized]
public Experiment requestedExperiment
Field Value
Type Description
Experiment
| Improve this Doc View Source

requestedExperimentGroup

Declaration
[NonSerialized]
public ExperimentGroup requestedExperimentGroup
Field Value
Type Description
ExperimentGroup
| Improve this Doc View Source

user

The currently logged in user. Will be null before log in.

Declaration
public User user
Field Value
Type Description
User

Properties

| Improve this Doc View Source

ClientSecret

Matches the client_secret field of the relevant game in the Game table in the server database. Is set on initial "Set Up" process, however if you need to update it, can be updated by running the set up process again.

Declaration
public static string ClientSecret { get; }
Property Value
Type Description
string
| Improve this Doc View Source

Configuration

The current configuration of the plugin. Contains the current experiment, experiment group, and active elements and parameters. However it is recommended to use the CurrentExperiment, CurrentExperimentGroup, CurrentElements and CurrentParameters properties instead.

Declaration
public Configuration Configuration { get; }
Property Value
Type Description
Configuration
| Improve this Doc View Source

CurrentBuildBranch

Current build branch of this build.

Declaration
public string CurrentBuildBranch { get; }
Property Value
Type Description
string
Exceptions
Type Condition
ConfigurationNotReadyException

thrown if configuration is not previously obtained

| Improve this Doc View Source

CurrentBuildID

Current build number of this experiment.

Declaration
public int CurrentBuildID { get; }
Property Value
Type Description
int
Exceptions
Type Condition
ConfigurationNotReadyException

thrown if configuration is not previously obtained

| Improve this Doc View Source

CurrentExperiment

Currently running experiment. Note this can be set at runtime as well, which will re-call Init() and trigger OnReady.

Declaration
public Experiment CurrentExperiment { get; set; }
Property Value
Type Description
Experiment
Exceptions
Type Condition
ConfigurationNotReadyException

thrown if configuration is not previously obtained

SessionAlreadyStartedException

thrown if trying to change experiment during a running session

| Improve this Doc View Source

CurrentExperimentGroup

Currently running experiment group.Note this can be set at runtime as well, which will re-call Init() and trigger OnReady.

Declaration
public ExperimentGroup CurrentExperimentGroup { get; set; }
Property Value
Type Description
ExperimentGroup
Exceptions
Type Condition
ConfigurationNotReadyException

thrown if configuration is not previously obtained

SessionAlreadyStartedException

thrown if trying to change experiment group during a running session

| Improve this Doc View Source

CurrentPlatform

Declaration
public Platform CurrentPlatform { get; }
Property Value
Type Description
Platform
| Improve this Doc View Source

CurrentSession

Declaration
public int CurrentSession { get; }
Property Value
Type Description
int
| Improve this Doc View Source

CurrentSessionRunning

Declaration
public bool CurrentSessionRunning { get; }
Property Value
Type Description
bool
| Improve this Doc View Source

GameID

Matches the id field of the relevant game in the Game table in the server database. Is set on initial "Set Up" process, however if you need to update it, can be updated by running the set up process again.

Declaration
public static int GameID { get; }
Property Value
Type Description
int
| Improve this Doc View Source

HasMTurkID

Determines if the game was launched with a MTurk ID defined. MTurk IDs are passed to the when launched in the web interface via the URL GET parameter defined in MTURK_URL_PARAM. When testing in the Unity Editor, this value can be overridden by setting PlayURPluginHelper.forceMTurkIDInEditor.

Declaration
public bool HasMTurkID { get; }
Property Value
Type Description
bool
| Improve this Doc View Source

IsReady

Used to determine if the plugin is ready for normal use (i.e. the user has logged in, and a configuration has been obtained.

Declaration
public static bool IsReady { get; }
Property Value
Type Description
bool

true if the user has logged in, and the configuration has been set. false if the user has not logged in yet, or a configuration could not be found.

| Improve this Doc View Source

MTurkID

Obtains the MTurk ID if it exists. MTurk IDs are passed to the when launched in the web interface via the URL GET parameter defined in MTURK_URL_PARAM. When testing in the Unity Editor, this value can be overridden by setting PlayURPluginHelper.forceMTurkIDInEditor. Will return null if the game was not launched with a MTurk ID.

Declaration
public string MTurkID { get; }
Property Value
Type Description
string
| Improve this Doc View Source

Ready

Declaration
[Obsolete("Use PlayURPlugin.IsReady instead.")]
public static bool Ready { get; }
Property Value
Type Description
bool
| Improve this Doc View Source

Settings

Declaration
public static PlayURSettings Settings { get; }
Property Value
Type Description
PlayURSettings

Methods

| Improve this Doc View Source

AddLeaderboardEntry(string, float, LeaderboardConfiguration, ServerCallback, params object[])

Declaration
public void AddLeaderboardEntry(string leaderboardID, float score, PlayURPlugin.LeaderboardConfiguration leaderBoardConfiguration, Rest.ServerCallback callback = null, params object[] extraFields)
Parameters
Type Name Description
string leaderboardID
float score
PlayURPlugin.LeaderboardConfiguration leaderBoardConfiguration
Rest.ServerCallback callback
object[] extraFields
| Improve this Doc View Source

AddLeaderboardEntryAndShowHighScoreTable(string, float, LeaderboardConfiguration, GameObject, Canvas, float, bool, KeyCode, CloseCallback, params object[])

Declaration
public void AddLeaderboardEntryAndShowHighScoreTable(string leaderboardID, float score, PlayURPlugin.LeaderboardConfiguration configuration, GameObject leaderboardPrefab = null, Canvas onCanvas = null, float height = -1, bool showCloseButton = true, KeyCode keyCodeForClose = KeyCode.None, HighScoreTable.CloseCallback closeCallback = null, params object[] extraFields)
Parameters
Type Name Description
string leaderboardID
float score
PlayURPlugin.LeaderboardConfiguration configuration
GameObject leaderboardPrefab
Canvas onCanvas
float height
bool showCloseButton
KeyCode keyCodeForClose
HighScoreTable.CloseCallback closeCallback
object[] extraFields
| Improve this Doc View Source

AddLeaderboardEntryAndShowHighScoreTableRoutine(string, float, LeaderboardConfiguration, GameObject, Canvas, float, bool, KeyCode, params object[])

Declaration
public IEnumerator AddLeaderboardEntryAndShowHighScoreTableRoutine(string leaderboardID, float score, PlayURPlugin.LeaderboardConfiguration configuration, GameObject leaderboardPrefab = null, Canvas onCanvas = null, float height = -1, bool showCloseButton = true, KeyCode keyCodeForClose = KeyCode.None, params object[] extraFields)
Parameters
Type Name Description
string leaderboardID
float score
PlayURPlugin.LeaderboardConfiguration configuration
GameObject leaderboardPrefab
Canvas onCanvas
float height
bool showCloseButton
KeyCode keyCodeForClose
object[] extraFields
Returns
Type Description
IEnumerator
| Improve this Doc View Source

Awake()

Basic Unity Singleton pattern. Triggers the initialization process. Also checks to see if the gameID and clientSecret is set. If gameID is not set, quits the application.

Declaration
public override void Awake()
Overrides
UnitySingletonPersistent<PlayURPlugin>.Awake()
| Improve this Doc View Source

BackupSessionAsync()

Backs up the current session

Declaration
public IEnumerator BackupSessionAsync()
Returns
Type Description
IEnumerator
| Improve this Doc View Source

BeginRecordAction(Action)

For more complex analytics, you can use this method to record an action across multiple sections of code. This function creates a new PlayURPlugin.InProgressAction which you can then build up by appending column data to it. Once you are done, call Record(bool, bool, bool) to upload the action to the server.

Declaration
public PlayURPlugin.InProgressAction BeginRecordAction(Action action)
Parameters
Type Name Description
Action action

The action type to record, as defind on the PlayUR back-end.

Returns
Type Description
PlayURPlugin.InProgressAction

The PlayURPlugin.InProgressAction to be used throughout the code, for later uploading.

| Improve this Doc View Source

ElementEnabled(Element)

Query if a certain element is enabled or not

Declaration
public bool ElementEnabled(Element element)
Parameters
Type Name Description
Element element
Returns
Type Description
bool

true if the given element is enabled.

Exceptions
Type Condition
ConfigurationNotReadyException

thrown if configuration is not previously obtained

| Improve this Doc View Source

EndSession(bool)

Records the end of a session.

Declaration
public void EndSession(bool startNew = false)
Parameters
Type Name Description
bool startNew

optionally immediately starts a new session after ending this one.

Exceptions
Type Condition
SessionNotStartedException

thrown if there is no session to end.

| Improve this Doc View Source

EndSessionAndStartANewOne()

Records the end of the current session and starts a new one. Is shorthand for EndSession(startNew: true);

Declaration
public void EndSessionAndStartANewOne()
| Improve this Doc View Source

EndSessionAsync(bool)

Records the end of a session.

Declaration
public IEnumerator EndSessionAsync(bool startNew = false)
Parameters
Type Name Description
bool startNew

optionally immediately starts a new session after ending this one.

Returns
Type Description
IEnumerator
Exceptions
Type Condition
SessionNotStartedException

thrown if there is no session to end.

| Improve this Doc View Source

GenerateUploadableActionData(InProgressAction, bool, bool, bool)

Declaration
protected PlayURPlugin.ActionParams GenerateUploadableActionData(PlayURPlugin.InProgressAction a, bool HTMLencode = false, bool debugOutput = false, bool waitForPendingActions = true)
Parameters
Type Name Description
PlayURPlugin.InProgressAction a
bool HTMLencode
bool debugOutput
bool waitForPendingActions
Returns
Type Description
PlayURPlugin.ActionParams
| Improve this Doc View Source

GetBoolParam(string)

Obtains an integer value of a parameter defined in the Configuration in string form. Uses whatever logic TryParse(string, out bool) uses to convert to bool.

Declaration
public bool GetBoolParam(string key)
Parameters
Type Name Description
string key

The key matching the parameter name set on the back-end

Returns
Type Description
bool

The boolean value of the requested parameter if it exists

Exceptions
Type Condition
ConfigurationNotReadyException

thrown if Configuration is not previously obtained

ParameterNotFoundException

thrown if no parameter with that name present in the Configuration

InvalidParamFormatException

thrown if the parameter was unable to be converted to a boolean

| Improve this Doc View Source

GetBoolParam(string, bool, bool)

Obtains an integer value of a parameter defined in the Configuration in string form. Uses whatever logic TryParse(string, out bool) uses to convert to bool. This version includes a defaultValue to return if the parameter is not found.

Declaration
public bool GetBoolParam(string key, bool defaultValue = false, bool warn = true)
Parameters
Type Name Description
string key

The key matching the parameter name set on the back-end

bool defaultValue
bool warn
Returns
Type Description
bool

The boolean value of the requested parameter if it exists

Exceptions
Type Condition
ConfigurationNotReadyException

thrown if Configuration is not previously obtained

ParameterNotFoundException

thrown if no parameter with that name present in the Configuration

InvalidParamFormatException

thrown if the parameter was unable to be converted to a boolean

| Improve this Doc View Source

GetBoolParamList(string)

Obtains a boolean array of values of a parameter defined in the Configuration.

Declaration
public bool[] GetBoolParamList(string key)
Parameters
Type Name Description
string key

The key matching the parameter name set on the back-end

Returns
Type Description
bool[]

The boolean array of value of the requested parameter if it exists

Exceptions
Type Condition
ConfigurationNotReadyException

thrown if Configuration is not previously obtained

ParameterNotFoundException

thrown if no parameter with that name present in the Configuration

InvalidParamFormatException

thrown if one or more values in the array were unable to be converted to a boolean

| Improve this Doc View Source

GetBoolParamList(string, bool[], bool)

Obtains a boolean array of values of a parameter defined in the Configuration. This version includes a defaultValue to return if the parameter is not found.

Declaration
public bool[] GetBoolParamList(string key, bool[] defaultValue, bool warn = true)
Parameters
Type Name Description
string key

The key matching the parameter name set on the back-end

bool[] defaultValue
bool warn
Returns
Type Description
bool[]

The boolean array of value of the requested parameter if it exists

Exceptions
Type Condition
ConfigurationNotReadyException

thrown if Configuration is not previously obtained

ParameterNotFoundException

thrown if no parameter with that name present in the Configuration

InvalidParamFormatException

thrown if one or more values in the array were unable to be converted to a boolean

| Improve this Doc View Source

GetDebugLogs(LogLevel)

Retrieves a history of all the debug messages printed out thus far

Declaration
public string GetDebugLogs(PlayURPlugin.LogLevel minimumLevel)
Parameters
Type Name Description
PlayURPlugin.LogLevel minimumLevel
Returns
Type Description
string
| Improve this Doc View Source

GetFloatParam(string)

Obtains the value of a parameter defined in the Configuration in float form.

Declaration
public float GetFloatParam(string key)
Parameters
Type Name Description
string key

The key matching the parameter name set on the back-end

Returns
Type Description
float

The float value of the requested parameter if it exists

Exceptions
Type Condition
ConfigurationNotReadyException

thrown if Configuration is not previously obtained

ParameterNotFoundException

thrown if no parameter with that name present in the Configuration

InvalidParamFormatException

thrown if the parameter was unable to be converted to a float

| Improve this Doc View Source

GetFloatParam(string, float, bool)

Obtains the value of a parameter defined in the Configuration in float form. This version includes a defaultValue to return if the parameter is not found.

Declaration
public float GetFloatParam(string key, float defaultValue = 0, bool warn = true)
Parameters
Type Name Description
string key

The key matching the parameter name set on the back-end

float defaultValue
bool warn
Returns
Type Description
float

The float value of the requested parameter if it exists

Exceptions
Type Condition
ConfigurationNotReadyException

thrown if Configuration is not previously obtained

ParameterNotFoundException

thrown if no parameter with that name present in the Configuration

InvalidParamFormatException

thrown if the parameter was unable to be converted to a float

| Improve this Doc View Source

GetFloatParamList(string)

Obtains a float array of values of a parameter defined in the Configuration.

Declaration
public float[] GetFloatParamList(string key)
Parameters
Type Name Description
string key

The key matching the parameter name set on the back-end

Returns
Type Description
float[]

The float array of value of the requested parameter if it exists

Exceptions
Type Condition
ConfigurationNotReadyException

thrown if Configuration is not previously obtained

ParameterNotFoundException

thrown if no parameter with that name present in the Configuration

InvalidParamFormatException

thrown if one or more values in the array were unable to be converted to an integer

| Improve this Doc View Source

GetFloatParamList(string, float[], bool)

Obtains a float array of values of a parameter defined in the Configuration. This version includes a defaultValue to return if the parameter is not found.

Declaration
public float[] GetFloatParamList(string key, float[] defaultValue, bool warn = true)
Parameters
Type Name Description
string key

The key matching the parameter name set on the back-end

float[] defaultValue
bool warn
Returns
Type Description
float[]

The float array of value of the requested parameter if it exists

Exceptions
Type Condition
ConfigurationNotReadyException

thrown if Configuration is not previously obtained

ParameterNotFoundException

thrown if no parameter with that name present in the Configuration

InvalidParamFormatException

thrown if one or more values in the array were unable to be converted to a float

| Improve this Doc View Source

GetIntParam(string)

Obtains the value of a parameter defined in the Configuration in integer form.

Declaration
public int GetIntParam(string key)
Parameters
Type Name Description
string key

The key matching the parameter name set on the back-end

Returns
Type Description
int

The integer value of the requested parameter if it exists

Exceptions
Type Condition
ConfigurationNotReadyException

thrown if Configuration is not previously obtained

ParameterNotFoundException

thrown if no parameter with that name present in the Configuration

InvalidParamFormatException

thrown if the parameter was unable to be converted to an integer

| Improve this Doc View Source

GetIntParam(string, int, bool)

Obtains the value of a parameter defined in the Configuration in integer form. This version includes a defaultValue to return if the parameter is not found.

Declaration
public int GetIntParam(string key, int defaultValue = -1, bool warn = true)
Parameters
Type Name Description
string key

The key matching the parameter name set on the back-end

int defaultValue
bool warn
Returns
Type Description
int

The integer value of the requested parameter if it exists

Exceptions
Type Condition
ConfigurationNotReadyException

thrown if Configuration is not previously obtained

ParameterNotFoundException

thrown if no parameter with that name present in the Configuration

InvalidParamFormatException

thrown if the parameter was unable to be converted to an integer

| Improve this Doc View Source

GetIntParamList(string)

Obtains a int array of values of a parameter defined in the Configuration.

Declaration
public int[] GetIntParamList(string key)
Parameters
Type Name Description
string key

The key matching the parameter name set on the back-end

Returns
Type Description
int[]

The int array of value of the requested parameter if it exists

Exceptions
Type Condition
ConfigurationNotReadyException

thrown if Configuration is not previously obtained

ParameterNotFoundException

thrown if no parameter with that name present in the Configuration

InvalidParamFormatException

thrown if one or more values in the array were unable to be converted to an integer

| Improve this Doc View Source

GetIntParamList(string, int[], bool)

Obtains a int array of values of a parameter defined in the Configuration. This version includes a defaultValue to return if the parameter is not found.

Declaration
public int[] GetIntParamList(string key, int[] defaultValue, bool warn = true)
Parameters
Type Name Description
string key

The key matching the parameter name set on the back-end

int[] defaultValue
bool warn
Returns
Type Description
int[]

The int array of value of the requested parameter if it exists

Exceptions
Type Condition
ConfigurationNotReadyException

thrown if Configuration is not previously obtained

ParameterNotFoundException

thrown if no parameter with that name present in the Configuration

InvalidParamFormatException

thrown if one or more values in the array were unable to be converted to an integer

| Improve this Doc View Source

GetLeaderboardEntries(string, LeaderboardConfiguration, ServerCallback)

Declaration
public void GetLeaderboardEntries(string leaderboardID, PlayURPlugin.LeaderboardConfiguration leaderBoardConfiguration, Rest.ServerCallback callback)
Parameters
Type Name Description
string leaderboardID
PlayURPlugin.LeaderboardConfiguration leaderBoardConfiguration
Rest.ServerCallback callback
| Improve this Doc View Source

GetLogin()

Loads the login scene. Waits until the PlayURLoginCanvas obtains a valid login.

Declaration
public static IEnumerator GetLogin()
Returns
Type Description
IEnumerator
| Improve this Doc View Source

GetMysqlFormatTime()

Helpful function that gets the current time in MySQL-ready format.

Declaration
public string GetMysqlFormatTime()
Returns
Type Description
string

The current time (in our timezone) in "yyyy-MM-dd HH:mm:ss" format

| Improve this Doc View Source

GetObjectParamList<T>(string)

Obtains a boolean array of values of a parameter defined in the Configuration.

Declaration
public T[] GetObjectParamList<T>(string key) where T : EntityData
Parameters
Type Name Description
string key

The key matching the parameter name set on the back-end

Returns
Type Description
T[]

The boolean array of value of the requested parameter if it exists

Type Parameters
Name Description
T
Exceptions
Type Condition
ConfigurationNotReadyException

thrown if Configuration is not previously obtained

ParameterNotFoundException

thrown if no parameter with that name present in the Configuration

InvalidParamFormatException

thrown if one or more values in the array were unable to be converted to a boolean

| Improve this Doc View Source

GetObjectParam<T>(string)

Obtains a object converted value of a parameter defined in the Configuration in string form.

Declaration
public T GetObjectParam<T>(string key) where T : EntityData
Parameters
Type Name Description
string key

The key matching the parameter name set on the back-end

Returns
Type Description
T

The object converted value of the requested parameter if it exists

Type Parameters
Name Description
T
Exceptions
Type Condition
ConfigurationNotReadyException

thrown if Configuration is not previously obtained

ParameterNotFoundException

thrown if no parameter with that name present in the Configuration

InvalidParamFormatException

thrown if the string json could not be converted to the requested type

| Improve this Doc View Source

GetStringParam(string)

Obtains a string value of a parameter defined in the Configuration in string form.

Declaration
public string GetStringParam(string key)
Parameters
Type Name Description
string key

The key matching the parameter name set on the back-end

Returns
Type Description
string

The string value of the requested parameter if it exists

Exceptions
Type Condition
ConfigurationNotReadyException

thrown if Configuration is not previously obtained

ParameterNotFoundException

thrown if no parameter with that name present in the Configuration

| Improve this Doc View Source

GetStringParam(string, string, bool)

Obtains a string value of a parameter defined in the Configuration in string form. This version includes a defaultValue to return if the parameter is not found.

Declaration
public string GetStringParam(string key, string defaultValue = "", bool warn = true)
Parameters
Type Name Description
string key

The key matching the parameter name set on the back-end

string defaultValue
bool warn
Returns
Type Description
string

The string value of the requested parameter if it exists

Exceptions
Type Condition
ConfigurationNotReadyException

thrown if Configuration is not previously obtained

ParameterNotFoundException

thrown if no parameter with that name present in the Configuration

| Improve this Doc View Source

GetStringParamList(string)

Obtains a string array of values of a parameter defined in the Configuration.

Declaration
public string[] GetStringParamList(string key)
Parameters
Type Name Description
string key

The key matching the parameter name set on the back-end

Returns
Type Description
string[]

The string array of value of the requested parameter if it exists

Exceptions
Type Condition
ConfigurationNotReadyException

thrown if Configuration is not previously obtained

ParameterNotFoundException

thrown if no parameter with that name present in the Configuration

| Improve this Doc View Source

GetStringParamList(string, string[], bool)

Obtains a string array of values of a parameter defined in the Configuration. This version includes a defaultValue to return if the parameter is not found.

Declaration
public string[] GetStringParamList(string key, string[] defaultValue, bool warn = true)
Parameters
Type Name Description
string key

The key matching the parameter name set on the back-end

string[] defaultValue
bool warn
Returns
Type Description
string[]

The string array of value of the requested parameter if it exists

Exceptions
Type Condition
ConfigurationNotReadyException

thrown if Configuration is not previously obtained

ParameterNotFoundException

thrown if no parameter with that name present in the Configuration

| Improve this Doc View Source

Init()

Logs in the user, and gets the configuration for that user. Loads scene #1 after this process is complete.

Declaration
public IEnumerator Init()
Returns
Type Description
IEnumerator
| Improve this Doc View Source

ListElements()

Gets all enabled Game Elements from the current configuration.

Declaration
public List<Element> ListElements()
Returns
Type Description
List<Element>

a list of the active Game Elements.

Exceptions
Type Condition
ConfigurationNotReadyException

thrown if configuration is not previously obtained

| Improve this Doc View Source

ListParameters()

Return a list of all parameters defined in the Configuration.

Declaration
public Dictionary<string, string> ListParameters()
Returns
Type Description
Dictionary<string, string>

The parameters in Dictionary format, keys are parameter names, values are the associated values.

Exceptions
Type Condition
ConfigurationNotReadyException
| Improve this Doc View Source

LoadPlayerPrefs(ServerCallback)

Loads playerprefs (overrides unity's ones) from the server. This code is automatically called on login.

Declaration
public void LoadPlayerPrefs(Rest.ServerCallback callback)
Parameters
Type Name Description
Rest.ServerCallback callback

Code to run once the player prefs have been loaded

| Improve this Doc View Source

Log(object, Object)

Logs an object's details to the Unity console, but with [PlayUR] in front, so as to be able to isolate plugin messages in unity. Could be used in the future to display on-screen log messages

Declaration
public static void Log(object o, Object context = null)
Parameters
Type Name Description
object o

The object to debug out

Object context

The context object that Unity uses for highlighting when you click on the log message (optional).

| Improve this Doc View Source

LogError(object, Object, bool)

Logs an object's as an Error to the Unity console, but with [PlayUR] in front, so as to be able to isolate plugin messages

Declaration
public static void LogError(object o, Object context = null, bool breakCode = false)
Parameters
Type Name Description
object o

The object to debug out

Object context

The context object that Unity uses for highlighting when you click on the log message (optional).

bool breakCode
| Improve this Doc View Source

LogWarning(object, Object)

Logs an object's as an Warning to the Unity console, but with [PlayUR] in front, so as to be able to isolate plugin messages

Declaration
public static void LogWarning(object o, Object context = null)
Parameters
Type Name Description
object o

The object to debug out

Object context

The context object that Unity uses for highlighting when you click on the log message (optional).

| Improve this Doc View Source

Login(string, string, ServerCallback)

Performs a log in request to the server. After the callback the user will be populated (if correct username and password).

Declaration
public void Login(string username, string password, Rest.ServerCallback callback)
Parameters
Type Name Description
string username

the username (not id) of the user. Entered in the PlayURLoginCanvas, or may be set by the WebGL integration.

string password

the password (or token) of the user. Entered in the PlayURLoginCanvas, or may be set by the WebGL integration.

Rest.ServerCallback callback

called when the response from the server is given, with a bool success and the user's information

| Improve this Doc View Source

Logout()

Logout the current user. Will move them to the PlayURLogin scene. Clears PlayerPref data that stored their password.

Declaration
public void Logout()
| Improve this Doc View Source

MarkMTurkComplete()

Record on PlayUR that the MTurk participant has completed the game. If successful, shows a popup in the corner with the Amazon MTurk Logo (as defined in PlayURPluginHelper.mTurkLogo) and the message defined in PlayURPluginHelper.mTurkCompletionMessage.

Declaration
public void MarkMTurkComplete()
Exceptions
Type Condition
InvalidMTurkState

If the game was not launched with a MTurkID.

| Improve this Doc View Source

OnApplicationQuit()

When Unity quits, it destroys objects in a random order. In principle, a Singleton is only destroyed when application quits. If any script calls Instance after it have been destroyed, it will create a buggy ghost object that will stay on the Editor scene even after stopping playing the Application. Really bad! So, this was made to be sure we're not creating that buggy ghost object.

Declaration
public override void OnApplicationQuit()
Overrides
UnitySingleton<PlayURPlugin>.OnApplicationQuit()
| Improve this Doc View Source

ParamExists(string)

Check if a given parameter key exists in the Configuration.

Declaration
public bool ParamExists(string key)
Parameters
Type Name Description
string key
Returns
Type Description
bool
Exceptions
Type Condition
ConfigurationNotReadyException
| Improve this Doc View Source

ParseConfigurationResult(bool, JSONNode, PlayURPlugin)

Declaration
public static Configuration ParseConfigurationResult(bool succ, JSONNode result = null, PlayURPlugin instance = null)
Parameters
Type Name Description
bool succ
JSONNode result
PlayURPlugin instance
Returns
Type Description
Configuration
| Improve this Doc View Source

PeriodicallyBackupSession()

Declaration
public IEnumerator PeriodicallyBackupSession()
Returns
Type Description
IEnumerator
| Improve this Doc View Source

RecordAction(Action, bool, params object[])

Record a single instance of an Action occuring. Note Action enum is enumerated in the editor to match actions defined on the server back-end.

Declaration
public void RecordAction(Action a, bool HTMLencode = false, params object[] extra)
Parameters
Type Name Description
Action a

the action to record

bool HTMLencode

Optionally convert form items special characters using

WebUtility.HtmlEncode
.
object[] extra

the additional meta data about this action (e.g. if end match, what was the score?) -- in this case an array of itmes which will be concatenated

| Improve this Doc View Source

RecordAction(Action, object, bool, bool, bool, Dictionary<AnalyticsColumn, object>)

Record a single instance of an Action occuring. Note Action enum is enumerated in the editor to match actions defined on the server back-end.

Declaration
public void RecordAction(Action a, object extra = null, bool HTMLencode = false, bool debugOutput = false, bool waitForPendingActions = true, Dictionary<AnalyticsColumn, object> columns = null)
Parameters
Type Name Description
Action a

The action type to record, as defind on the PlayUR back-end.

object extra

the additional meta data about this action (e.g. if end match, what was the score?)

bool HTMLencode

Optionally convert form items special characters using

WebUtility.HtmlEncode
.
bool debugOutput

Optionally debug to the Unity console a bunch of information about how the request occurred.

bool waitForPendingActions

Optionally wait for any previous requests to complete before sending this one (note, original timestamp will be preserved) -- defaults to true.

Dictionary<AnalyticsColumn, object> columns

Optionally any custom-set up columns and their data. For complex data, use BeginRecordAction(Action) instead.

| Improve this Doc View Source

Register(string, string, string, string, string, ServerCallback)

Performs a register request to the server. After the callback the user will be populated (if correct username and password).

Declaration
public void Register(string username, string password, string email, string firstName, string lastName, Rest.ServerCallback callback)
Parameters
Type Name Description
string username

the username of the new user. Entered in the PlayURLoginCanvas.

string password

the password of the new user. Entered in the PlayURLoginCanvas.

string email

the email of the new user. Entered in the PlayURLoginCanvas.

string firstName

the first name of the new user. Entered in the PlayURLoginCanvas. Optional, leave as empty string to skip.

string lastName

the last name of the new user. Entered in the PlayURLoginCanvas. Optional, leave as empty string to skip.

Rest.ServerCallback callback

called when the response from the server is given, with a bool success and the user's information

| Improve this Doc View Source

SavePlayerPrefs(Dictionary<string, object>, bool, bool)

Saves playerprefs (overrides unity's ones) to the server.

Declaration
public void SavePlayerPrefs(Dictionary<string, object> DATA, bool HTMLencode = false, bool debugOutput = false)
Parameters
Type Name Description
Dictionary<string, object> DATA

The data to save, should come from PlayerPrefs class

bool HTMLencode

Optionally convert form items special characters using

WebUtility.HtmlEncode
.
bool debugOutput

Optionally debug to the Unity console a bunch of information about how the request occurred.

| Improve this Doc View Source

ShowCloseablePopup(string, Sprite)

Shows a popup message with a given text and image. Requires that a popup prefab is set in the PlayURPluginHelper.

Declaration
public void ShowCloseablePopup(string text, Sprite image = null)
Parameters
Type Name Description
string text

The text to show in the popup.

Sprite image

The sprite image to show in the popup.

| Improve this Doc View Source

ShowHighScoreTable(string, LeaderboardConfiguration, int, GameObject, Canvas, float, bool, KeyCode, CloseCallback)

Declaration
public GameObject ShowHighScoreTable(string leaderboardID, PlayURPlugin.LeaderboardConfiguration configuration, int highlightRowID = -1, GameObject leaderboardPrefab = null, Canvas onCanvas = null, float height = -1, bool showCloseButton = true, KeyCode keyCodeForClose = KeyCode.None, HighScoreTable.CloseCallback closeCallback = null)
Parameters
Type Name Description
string leaderboardID
PlayURPlugin.LeaderboardConfiguration configuration
int highlightRowID
GameObject leaderboardPrefab
Canvas onCanvas
float height
bool showCloseButton
KeyCode keyCodeForClose
HighScoreTable.CloseCallback closeCallback
Returns
Type Description
GameObject
| Improve this Doc View Source

ShowHighScoreTableFor(float, string, LeaderboardConfiguration, int, GameObject, Canvas, float, bool, KeyCode)

Declaration
public IEnumerator ShowHighScoreTableFor(float seconds, string leaderboardID, PlayURPlugin.LeaderboardConfiguration configuration, int highlightRowID = -1, GameObject leaderboardPrefab = null, Canvas onCanvas = null, float height = -1, bool showCloseButton = false, KeyCode keyCodeForClose = KeyCode.Delete)
Parameters
Type Name Description
float seconds
string leaderboardID
PlayURPlugin.LeaderboardConfiguration configuration
int highlightRowID
GameObject leaderboardPrefab
Canvas onCanvas
float height
bool showCloseButton
KeyCode keyCodeForClose
Returns
Type Description
IEnumerator
| Improve this Doc View Source

ShowHighScoreTableRoutine(string, LeaderboardConfiguration, int, GameObject, Canvas, float, bool, KeyCode)

Declaration
public IEnumerator ShowHighScoreTableRoutine(string leaderboardID, PlayURPlugin.LeaderboardConfiguration configuration, int highlightRowID = -1, GameObject leaderboardPrefab = null, Canvas onCanvas = null, float height = -1, bool showCloseButton = true, KeyCode keyCodeForClose = KeyCode.Delete)
Parameters
Type Name Description
string leaderboardID
PlayURPlugin.LeaderboardConfiguration configuration
int highlightRowID
GameObject leaderboardPrefab
Canvas onCanvas
float height
bool showCloseButton
KeyCode keyCodeForClose
Returns
Type Description
IEnumerator
| Improve this Doc View Source

ShowPopup(string, Sprite, float)

Shows a popup message with a given text and image for a given duration of time. Requires that a popup prefab is set in the PlayURPluginHelper.

Declaration
public void ShowPopup(string text, Sprite image = null, float duration = 2)
Parameters
Type Name Description
string text

The text to show in the popup.

Sprite image

The sprite image to show in the popup.

float duration

The duration of time to show the popup for.

| Improve this Doc View Source

ShowSurveyPopup(Survey)

Display a survey to the user.

Declaration
public SurveyPopup ShowSurveyPopup(Survey survey)
Parameters
Type Name Description
Survey survey

The survey scriptable object defining the survey to show.

Returns
Type Description
SurveyPopup

A reference to the instantiated survey popup gameobject.

| Improve this Doc View Source

ShowSurveyPopupWithCoroutine(Survey)

Display a survey to the user and wait for it to be completed. To be called within StartCoroutine.

Declaration
public IEnumerator ShowSurveyPopupWithCoroutine(Survey survey)
Parameters
Type Name Description
Survey survey

The survey scriptable object defining the survey to show.

Returns
Type Description
IEnumerator
| Improve this Doc View Source

StartSession()

Starts logging a new session (if not already in a session). Records system information, note that on WebGL, returned information may be inconsistent or incorrect, based upon browser compatability--use with caution.

Declaration
public void StartSession()
Exceptions
Type Condition
SessionAlreadyStartedException

thrown if there is already a running session.

| Improve this Doc View Source

StartSessionAsync()

Starts logging a new session (if not already in a session). Records system information, note that on WebGL, returned information may be inconsistent or incorrect, based upon browser compatability--use with caution.

Declaration
public IEnumerator StartSessionAsync()
Returns
Type Description
IEnumerator
Exceptions
Type Condition
SessionAlreadyStartedException

thrown if there is already a running session.

| Improve this Doc View Source

UpdateLeaderboardEntryName(int, string, ServerCallback)

Declaration
public void UpdateLeaderboardEntryName(int id, string name, Rest.ServerCallback callback)
Parameters
Type Name Description
int id
string name
Rest.ServerCallback callback
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX