# Overview Unity

The [Openfort Unity SDK](https://github.com/openfort-xyz/openfort-csharp-unity) is a Unity library client for Openfort that allows you to add secure authentication, non-custodial embedded wallets, and powerful UX infrastructure into your game.

:::note\[Supported platforms]

* Windows (64-bit, Mono backend only — IL2CPP not supported)
* macOS (minimum version 12.5)
* Android (minimum version 5.1)
* iOS (minimum version 15.2)
  :::

:::info\[TARGET PLATFORM VS UNITY EDITOR PLATFORM]

* Unity 2021.3 or newer for Windows, macOS, Android and iOS
* Unity 2019.4 or newer for macOS, Android, and iOS. Windows isn't supported on Unity versions from 2019.4 up through 2021.2.

We have added compilation flags to the Unity SDK to ensure that specific Unity editors can only build certain platform targets. Please note that the table below indicates which editor you can use to build a platform target, but it does not determine whether you can run the SDK in that editor.

For example, the SDK allows you to build iOS games using a macOS Unity Editor, but you cannot use the Windows Unity Editor.

| Target Platform | Windows Unity Editor | macOS Unity Editor |
|-----------------|:---------------------:|:-------------------:|
| Windows         | ✅                   | ❌                 |
| macOS           | ❌                   | ✅                 |
| Android        | ✅                   | ✅                 |
| iOS             | ❌                   | ✅                 |
| Web             | ✅                   | ✅                 |
:::

## Get started

Check out these popular guides to get started.

<HoverCardLayout>
  {/* Setting up the SDK */}

  <HoverCardLink description="Setting up and importing a project" href="/products/embedded-wallet/unity/quickstart" title="Setting up the SDK" subtitle="Project setup & import" icon={Settings} color="#6B5BFF" />

  {/* WebGL */}

  <HoverCardLink description="Using embedded wallets with WebGL" href="/products/embedded-wallet/unity/webgl" title="WebGL" subtitle="Web deployment" icon={Globe} color="#0EA5E9" />

  {/* Embedded wallet */}

  <HoverCardLink description="Create an embedded wallet" href="/products/embedded-wallet/unity/signer/recovery" title="Embedded Wallet" subtitle="Wallet creation & recovery" icon={Wallet} color="#16A34A" />
</HoverCardLayout>

## Templates

Check out these popular samples to get started.

<HoverCardLayout>
  {/* Unity Sample */}

  <HoverCardLink description="Check our latest Unity sample" href="https://github.com/openfort-xyz/openfort-csharp-unity/tree/main/sample" title="Unity Sample" subtitle="Complete example project" icon={Code} color="#F59E0B" />
</HoverCardLayout>

## SDK Reference

The Unity SDK provides the following main components:

### OpenfortSDK Class

The `OpenfortSDK` class is the main entry point for interacting with the SDK.

| Method | Description |
|--------|-------------|
| `Init(publishableKey, ...)` | Initialize the SDK singleton |
| `OnAuthEvent` | Event for authentication state changes |

### Authentication Methods

| Method | Description |
|--------|-------------|
| `SignUpGuest()` | Sign up as guest user |
| `LogInWithEmailPassword()` | Log in with email and password |
| `SignUpWithEmailPassword()` | Sign up with email and password |
| `RequestEmailOtp()` | Request OTP to email |
| `LogInWithEmailOtp()` | Log in with email OTP |
| `VerifyEmailOtp()` | Verify email using OTP |
| `RequestPhoneOtp()` | Request OTP to phone |
| `LogInWithPhoneOtp()` | Log in with phone OTP |
| `LinkPhoneOtp()` | Link phone number with OTP |
| `AddEmail()` | Add email to account |
| `InitOAuth()` | Initialize OAuth flow |
| `InitLinkOAuth()` | Initialize OAuth linking |
| `UnlinkOAuth()` | Unlink OAuth provider |

:::warning\[OAuth not available with Openfort auth in Unity]
OAuth flows (Google, Twitter/X, Facebook, Discord, etc.) are **not available** when using Openfort's built-in authentication in Unity. If you need OAuth-based social login in your Unity game, use a [third-party auth provider](/docs/products/embedded-wallet/unity/auth/third-party) such as Firebase, Supabase, or Auth0, and pass the resulting JWT token to Openfort.
:::

| `InitSiwe()` | Initialize SIWE authentication |
| `LoginWithSiwe()` | Log in with SIWE |
| `InitLinkSiwe()` | Initialize SIWE linking |
| `LinkWithSiwe()` | Link wallet with SIWE |
| `UnlinkWallet()` | Unlink wallet from account |
| `LogInWithIdToken()` | Log in with external ID token |
| `RequestResetPassword()` | Request password reset |
| `ResetPassword()` | Reset password with token |
| `RequestEmailVerification()` | Request email verification |
| `VerifyEmail()` | Verify email with token |

### Session Management

| Method | Description |
|--------|-------------|
| `GetUser()` | Get current user info |
| `Logout()` | Log out and remove credentials |
| `GetAccessToken()` | Get saved access token |
| `ValidateAndRefreshToken()` | Validate and refresh token |
| `StoreCredentials()` | Store authentication credentials |
| `SetCallTimeout()` | Set browser communication timeout (ms) |
| `ClearCache()` | Clear underlying WebView cache |
| `ClearStorage()` | Clear underlying WebView storage |

### Embedded Wallet Methods

| Method | Description |
|--------|-------------|
| `GetEmbeddedState()` | Get embedded wallet state |
| `GetEthereumProvider()` | Get Ethereum provider interface |
| `CreateEmbeddedWallet()` | Create new embedded wallet |
| `RecoverEmbeddedWallet()` | Recover embedded wallet |
| `GetEmbeddedWallet()` | Get current embedded wallet |
| `ListWallets()` | List all wallets |
| `ConfigureEmbeddedWallet()` | Configure embedded wallet |

### Transaction/Signing Methods

| Method | Description |
|--------|-------------|
| `SendSignatureTransactionIntentRequest()` | Sign and send transaction intent |
| `SignMessage()` | Sign a message (EIP-191) |
| `SignTypedData()` | Sign typed data (EIP-712) |

### Enums

| Enum | Values |
|------|--------|
| `EmbeddedState` | `NONE`, `UNAUTHENTICATED`, `EMBEDDED_SIGNER_NOT_CONFIGURED`, `CREATING_ACCOUNT`, `READY` |
| `OAuthProvider` | `GOOGLE`, `TWITTER`, `APPLE`, `FACEBOOK`, `DISCORD`, `EPIC_GAMES`, `LINE` (see [warning above](#authentication-methods)) |
| `ChainType` | `EVM`, `SVM` |
| `AccountType` | `EOA`, `SMART_ACCOUNT`, `DELEGATED_ACCOUNT` |
| `RecoveryMethod` | `PASSWORD`, `AUTOMATIC` |

### Events

| Enum | Values |
|------|--------|
| `OpenfortAuthEvent` | `LoggingIn`, `LoginFailed`, `LoginSuccess`, `LoggingOut`, `LogoutFailed`, `LogoutSuccess`, `ReloggingIn`, `ReloginFailed`, `ReloginSuccess`, `Reconnecting`, `ReconnectFailed`, `ReconnectSuccess`, `CheckingForSavedCredentials`, `CheckForSavedCredentialsFailed`, `CheckForSavedCredentialsSuccess` |

### Error Handling
