Interacting with Particle Auth within games built on Unity using C#.
Due to limitations with Webview, Particle Auth for Unity on Windows & macOS does not include most built-in social logins
Options include email, phone, and custom JWT authentication (indicated by ‘email’, ‘phone’, or ‘jwt’).
GameObject
to your scene.ParticleSystem
script to this GameObject.CanvasWebViewPrefab
to the ParticleSystem
script.ParticleUnityRpc
prefab into your scene.project id
, app id
, and client key
.ParticleSystem
(similar to the ParticleNetwork
in the Web SDK).
Init
method on ParticleSystem.Instance
with the following parameters:
config
: Includes ParticleConfigSecurityAccount
and ParticleConfigWallet
.
theme
: Controls the theme settings such as dark or light mode, whether to display the wallet or show the close button.
language
: A string indicating the UI language, options include ‘en-US’, ‘zh-CN’, ‘zh-TW’, ‘ja-JP’, or ‘ko-KR’.
chainInfo
: An object that specifies the primary blockchain to be used.
ParticleUnityRpc
prefab containing project id
, app id
and client key
are the most important. It directly connects your instance of Particle’s Wallet-as-a-Service with your configurations in the Particle dashboard.
ParticleSystem.Instance.Login
displays the login popup, set to ‘email’, ‘phone’, or custom JWT authentication with ‘jwt’.
This popup acts as the primary mechanism for facilitating account creation.
ParticleSystem.Instance.SignMessage
enables the signing of a basic string.
This can be passed directly within SignMessage
for EVM chains, as shown below.
For Solana, you’ll need to convert this string to base58 before SignMessage
will function properly. The confirmation popup will display this string, base58 or otherwise, in UTF-8.
ParticleSystem.Instance.SignAndSendTransaction
method takes a transaction object constructed by ParticleSystem.Instance.MakeEvmTransaction
(for EVM chains). It then prompts the user for confirmation (signature).
Once the user confirms, the transaction will be sent.
ParticleSystem.Instance.SignTypedData
facilitates the signature of structured data; by default, this uses eth_signTypedData_v4
.
For more information on signTypedData
, see the Web (JavaScript/TypeScript) page.
ParticleSystem.Instance.SignTransaction
is a Solana-specific method for requesting a signature for a given transaction.
This will sign (but not send) a transaction.
ParticleSystem.Instance.SignAllTransactions
is the plural of those mentioned above; this is also *Solana-specific
ParticleSystem.Instance.OpenWebWallet
can open the web wallet.
ParticleSystem
alongside specific parameters and a short description for a direct, raw view.
For methods listed that needed to be covered in the above examples, live implementation often mimics the standard structure covered throughout this document.
Class | Methods | Parameters |
---|---|---|
ParticleSystem | Init | config, theme, language, chainName, chainId |
ParticleSystem | Login | preferredAuthType, account |
ParticleSystem | SignMessage | message |
ParticleSystem | SignAndSendTransaction | transaction |
ParticleSystem | SignTypedData | message, version |
ParticleSystem | SignTransaction | transaction |
ParticleSystem | SignAllTransactions | transactions |
ParticleSystem | MakeEvmTransaction | from, to, data, value |
ParticleSystem | UpdateChainId | chainId |
ParticleSystem | UpdateChainName | chainName |