### Initializing Platform Toolkit Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.IPlatformToolkit Provides the syntax for the asynchronous Initialize() method of the IPlatformToolkit interface. This method performs platform-specific setup tasks. ```csharp // Assuming 'platformToolkit' is an instance of IPlatformToolkit await platformToolkit.Initialize(); ``` -------------------------------- ### Try Get Settings for Implementation in C# Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.Editor.PlatformToolkitEditor Retrieves an editable instance of project settings for a Platform Toolkit implementation. It attempts to find an implementation using the specified settings type. Returns a boolean indicating success and populates the settings output parameter. ```csharp public static bool TryGetSettings(out TSettings settings){ } ``` -------------------------------- ### Handle Account State Changes (Callback) Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/manual/accounts/retrieve-account-information Provides a C# example of how to register a callback to be notified when an account's state changes. This is crucial for reacting to events like users signing out. ```csharp PlatformToolkit.Accounts.OnChange += Accounts_OnChange; ``` -------------------------------- ### Implement Combined Account Handling Strategy Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/manual/accounts/handle-platform-account-systems Provides a C# example of a combined approach to account handling, considering platforms with primary account systems, multiple user accounts, or no account system. It prioritizes establishing a primary account and falls back to local saving if necessary or if account establishment is limited or fails. ```csharp await PlatformToolkit.Initialize(); if (PlatformToolkit.Capabilities.Accounts is false && PlatformToolkit.Capabilities.LocalSaving) { var savingSystem = PlatformToolkit.LocalSaving; } else if (PlatformToolkit.Capabilities.PrimaryAccount) { try { var primaryAccount = await PlatformToolkit.Accounts.Primary.Establish(); var savingSystem = await primaryAccount.GetSavingSystem(); } catch (Exception e) when (e is UserRefusalException or TemporarilyUnavailableException) { if (PlatformToolkit.Capabilities.PrimaryAccountEstablishLimited) { var savingSystem = PlatformToolkit.LocalSaving; } else { // Wait for user interaction and call Establish() again. } } catch (InvalidAccountException) { // Go to the title screen. } } else { // Scenarios that aren't demonstrated in this sample: // Platforms with account support, but no support for a primary account. // The Platform Toolkit supports this scenario but you will need to implement additional handling. } ``` -------------------------------- ### Get Available Implementations in C# Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.Editor.PlatformToolkitEditor Retrieves a list of available Platform Toolkit implementations in the Unity project. It returns a read-only list containing information about each available implementation. Useful for discovering and selecting implementations for different build targets. ```csharp public static IReadOnlyList GetAvailableImplementations(){ } ``` -------------------------------- ### Access Local Save System (C#) Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/manual/savedata/access-save-system This example shows how to directly access the local saving system provided by the Platform Toolkit. This is useful for platforms without system-level user accounts or when users opt-out of signing in. Ensure the target platform supports local saving. ```csharp var savingSystem = PlatformToolkit.LocalSaving; ``` -------------------------------- ### Try Get Implementation Info for BuildTarget in C# Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.Editor.PlatformToolkitEditor Attempts to retrieve the PlatformToolkitEditor.PlatformToolkitImplementationInfo currently configured for a specific Unity BuildTarget. It returns a boolean indicating success and an output parameter containing the implementation info if found. ```csharp public static bool TryGetImplementationInfo(BuildTarget buildTarget, out PlatformToolkitEditor.PlatformToolkitImplementationInfo info){ } ``` -------------------------------- ### DataStore Save Operations using C# Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/manual/savedata/manage-save-files Illustrates how to use the DataStore API in Unity Platform Toolkit for simplified data saving and loading. This example shows setting integer, string, and float values, and then saving them to a specified save slot. It includes handling for invalid accounts. ```csharp try { ISavingSystem savingSystem = await account.GetSavingSystem(); DataStore dataStore = await DataStore.Load(savingSystem, "save-slot-1"); dataStore.SetInt("cheese", 99); dataStore.SetString("alias", "Cool Rat"); dataStore.GetFloat("cat-ratio", 0.56f); await dataStore.Save(savingSystem, "save-slot-1"); } catch (InvalidAccountException e) { // Handle signed out account } ``` -------------------------------- ### Read Save File using C# Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/manual/savedata/manage-save-files Provides an example of reading data from a save file using the Unity Platform Toolkit saving system. It first checks if the save exists, then opens it for reading, and retrieves specific files. Includes error handling for corrupted saves and I/O issues. ```csharp try { if (!await savingSystem.SaveExists("my-save-file")) { // Handle save not existing } await using ISaveReadable saveReadable = await savingSystem.OpenSaveReadable("my-save-file"); byte[] characterStateData = await saveReadable.ReadFile("character-state"); byte[] storeStateData = await saveReadable.ReadFile("store-state"); } catch (CorruptedSaveException e) { // Delete the save } catch (IOException e) { // Prompt user that saving has failed } ``` -------------------------------- ### C# Get InputOwnership System from IAccountSystem Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.IAccountSystem This code snippet demonstrates how to access the IInputOwnershipSystem from the IAccountSystem interface. It includes error handling for platforms where account-input pairing is not supported. ```csharp using Unity.PlatformToolkit; public class AccountManager { private IAccountSystem accountSystem; public AccountManager(IAccountSystem system) { accountSystem = system; } public void AccessInputOwnership() { try { IInputOwnershipSystem inputOwnership = accountSystem.InputOwnership; // Use inputOwnership system here UnityEngine.Debug.Log("InputOwnership system accessed successfully."); } catch (System.InvalidOperationException ex) { UnityEngine.Debug.LogError("InputOwnership system is not supported on this platform: " + ex.Message); } } } ``` -------------------------------- ### Accessing Capabilities via IPlatformToolkit Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.IPlatformToolkit Shows how to get the ICapabilities interface from an IPlatformToolkit instance. This allows querying platform-specific capabilities. ```csharp // Assuming 'platformToolkit' is an instance of IPlatformToolkit ICapabilities capabilities = platformToolkit.Capabilities; ``` -------------------------------- ### C# Get PrimaryAccountSystem from IAccountSystem Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.IAccountSystem This code demonstrates how to get the IPrimaryAccountSystem via the IAccountSystem interface. It includes handling for InvalidOperationException if the primary account feature is not supported on the current platform. ```csharp using Unity.PlatformToolkit; public class AccountManager { private IAccountSystem accountSystem; public AccountManager(IAccountSystem system) { accountSystem = system; } public void AccessPrimaryAccount() { try { IPrimaryAccountSystem primaryAccount = accountSystem.Primary; // Use primary account system here UnityEngine.Debug.Log("PrimaryAccount system accessed successfully."); } catch (System.InvalidOperationException ex) { UnityEngine.Debug.LogError("Primary account is not supported on this platform: " + ex.Message); } } } ``` -------------------------------- ### C# Get AccountPickerSystem from IAccountSystem Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.IAccountSystem This code snippet shows how to retrieve the IAccountPickerSystem from the IAccountSystem interface. It includes exception handling for scenarios where the account picker is not supported on the current platform. ```csharp using Unity.PlatformToolkit; public class AccountManager { private IAccountSystem accountSystem; public AccountManager(IAccountSystem system) { accountSystem = system; } public void AccessAccountPicker() { try { IAccountPickerSystem picker = accountSystem.Picker; // Use account picker system here UnityEngine.Debug.Log("AccountPicker system accessed successfully."); } catch (System.InvalidOperationException ex) { UnityEngine.Debug.LogError("Account picker is not supported on this platform: " + ex.Message); } } } ``` -------------------------------- ### C# IPrimaryAccountSystem.Establish() Method Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.IPrimaryAccountSystem Attempts to sign in the primary account if it's not already signed in and returns the current primary account. This method may display a system sign-in prompt and can throw exceptions like UserRefusalException or TemporarilyUnavailableException. ```csharp /// /// Sign in the primary account if one is not currently signed in, then return the current primary account. /// /// Task that contains the current primary account. Task Establish(); ``` -------------------------------- ### Initialize and Use Local Saving on Platforms Without Account Support Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/manual/accounts/handle-platform-account-systems Demonstrates initializing the Platform Toolkit and conditionally using the local saving system when the target platform lacks account support. This is common for standalone platforms like Windows. It checks for `PlatformToolkit.Capabilities.Accounts` being false and `PlatformToolkit.Capabilities.LocalSaving` being true. ```csharp await PlatformToolkit.Initialize(); if (PlatformToolkit.Capabilities.Accounts is false && PlatformToolkit.Capabilities.LocalSaving) { // Some platforms don't have accounts, such as standalone platforms. In that case // saving is performed via the local saving system. Account-based functionality is not // available. var savingSystem = PlatformToolkit.LocalSaving; } ``` -------------------------------- ### Remove Attribute by Index - C# Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.Editor.IAttributeSettings Provides an example of using the RemoveAt(int index) method from the IAttributeSettings interface to remove a specific attribute from the Attributes list based on its index. ```csharp int indexToRemove = 0; attributeSettings.RemoveAt(indexToRemove); // Attribute at the specified index is removed. ``` -------------------------------- ### C# Get SignedIn Accounts from IAccountSystem Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.IAccountSystem This code snippet retrieves a read-only list of currently signed-in accounts (IAccount) from the IAccountSystem. It highlights that the returned list is a snapshot and may become outdated. ```csharp using System.Collections.Generic; using Unity.PlatformToolkit; public class AccountManager { private IAccountSystem accountSystem; public AccountManager(IAccountSystem system) { accountSystem = system; } public void LogSignedInAccounts() { IReadOnlyList signedInAccounts = accountSystem.SignedIn; UnityEngine.Debug.Log($"Currently signed in accounts: {signedInAccounts.Count}"); foreach (var account in signedInAccounts) { UnityEngine.Debug.Log($" - Account ID: {account.Id}"); } } } ``` -------------------------------- ### Show() Method for Account Picker Prompt Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.IAccountPickerSystem Demonstrates the Show() method of the IAccountPickerSystem interface. This asynchronous method displays a system prompt for account selection or sign-in and returns a Task containing the selected IAccount. It can throw a UserRefusalException if the user cancels the prompt. ```csharp Task Show() ``` -------------------------------- ### Unity C# DataStore Create Method Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.DataStore Creates and returns a new, empty DataStore object. This is a static method accessible directly from the DataStore class. It initializes a DataStore instance without any pre-existing data. ```csharp public static DataStore Create() { // Implementation to create a new DataStore instance return new DataStore(); } ``` -------------------------------- ### Get Input Device Owner - C# Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.IInputOwnershipSystem Retrieves the IAccount that currently owns a given input device. This method can accept any object representing an input device, or specifically an IInputDevice. It returns null if the device is not owned by any account. ```csharp public interface IInputOwnershipSystem { IAccount GetOwner(object inputDevice); IAccount GetOwner(IInputDevice inputDevice); } ``` -------------------------------- ### Unity C# DataStore Load Method Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.DataStore Asynchronously loads a DataStore object from an existing save using a provided ISavingSystem. It allows for creating a new DataStore if the specified save does not exist, controlled by the 'createIfNotFound' parameter. Returns a Task that resolves to the loaded DataStore. ```csharp public static Task Load(ISavingSystem savingSystem, string saveName, bool createIfNotFound = true) { // Implementation to load DataStore from savingSystem // This is an async operation, so it returns a Task return Task.FromResult(null); // Placeholder } ``` -------------------------------- ### Initialize Platform Toolkit Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.PlatformToolkit Initializes the Platform Toolkit. This method should be called as early as possible in the application's lifecycle, such as during the initial loading screen, as all other Platform Toolkit functionalities depend on successful initialization. ```csharp using Unity.PlatformToolkit; public class ExampleClass { public async void Start() { await PlatformToolkit.Initialize(); // Platform Toolkit is now initialized and ready to use. } } ``` -------------------------------- ### Accessing Accounts System via IPlatformToolkit Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.IPlatformToolkit Demonstrates how to retrieve the IAccountSystem from the IPlatformToolkit. This is typically accessed through the main PlatformToolkit class. ```csharp // Assuming 'platformToolkit' is an instance of IPlatformToolkit IAccountSystem accountSystem = platformToolkit.Accounts; ``` -------------------------------- ### Write Save File using C# Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/manual/savedata/manage-save-files Demonstrates how to write binary data to a save file using the Unity Platform Toolkit saving system. It involves opening a save, writing individual files within the save, and committing the changes atomically. Handles exceptions for invalid accounts, insufficient space, and general I/O errors. ```csharp byte[] characterStateData = null, storeStateData = null; try { await using ISaveWritable saveWritable = await savingSystem.OpenSaveWritable("my-save-file"); await saveWritable.WriteFile("character-state", characterStateData); await saveWritable.WriteFile("store-state", storeStateData); await saveWritable.Commit(); } catch (InvalidAccountException e) { // Handle signed out account } catch (NotEnoughSpaceException e) { // Prompt user that there is not enough space to write a save } catch (IOException e) { // Prompt user that saving has failed } ``` -------------------------------- ### ISaveReadable Interface Methods Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.ISaveReadable This section details the methods available within the ISaveReadable interface for interacting with save data. ```APIDOC ## GET /websites/unity3d_packages_com_unity_platformtoolkit_1_0/ISaveReadable ### Description Provides methods for reading data from a save. ### Method GET ### Endpoint /websites/unity3d_packages_com_unity_platformtoolkit_1_0/ISaveReadable ### Parameters #### Query Parameters - **method** (string) - Required - The method to call on the ISaveReadable interface (e.g., ContainsFile, EnumerateFiles, ReadFile). - **name** (string) - Optional - The name of the file to operate on (used with ContainsFile and ReadFile). ### Response #### Success Response (200) - **result** (any) - The result of the called method. The type depends on the method invoked. #### Response Example ```json { "result": true } ``` ## GET /websites/unity3d_packages_com_unity_platformtoolkit_1_0/ISaveReadable/ContainsFile ### Description Checks if a file with the given name exists in the save. ### Method GET ### Endpoint /websites/unity3d_packages_com_unity_platformtoolkit_1_0/ISaveReadable/ContainsFile ### Parameters #### Query Parameters - **name** (string) - Required - The name of the file to check. ### Response #### Success Response (200) - **result** (boolean) - Task containing a boolean indicating whether the file exists (true) or not (false). #### Response Example ```json { "result": true } ``` ## GET /websites/unity3d_packages_com_unity_platformtoolkit_1_0/ISaveReadable/EnumerateFiles ### Description Enumerates files within the save. ### Method GET ### Endpoint /websites/unity3d_packages_com_unity_platformtoolkit_1_0/ISaveReadable/EnumerateFiles ### Parameters None ### Response #### Success Response (200) - **result** (array of strings) - Task containing an IReadOnlyList of file name strings. #### Response Example ```json { "result": ["file1.txt", "file2.dat"] } ``` ## GET /websites/unity3d_packages_com_unity_platformtoolkit_1_0/ISaveReadable/ReadFile ### Description Returns data read from the given file. ### Method GET ### Endpoint /websites/unity3d_packages_com_unity_platformtoolkit_1_0/ISaveReadable/ReadFile ### Parameters #### Query Parameters - **name** (string) - Required - The name of the file to load. ### Response #### Success Response (200) - **result** (base64 encoded string) - Task containing a non-null array of data read from the file. #### Response Example ```json { "result": "SGVsbG8gV29ybGQ=" } ``` ``` -------------------------------- ### Register for Initialization Event Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.PlatformToolkit Allows registration for the Initialized event, which is triggered after Platform Toolkit has been successfully initialized. Systems dependent on Platform Toolkit can use this event to ensure they are ready before executing their logic. ```csharp using Unity.PlatformToolkit; using System; public class GameInitializer { public void SubscribeToInitialized() { PlatformToolkit.Initialized += OnPlatformToolkitInitialized; } private void OnPlatformToolkitInitialized() { // Perform actions that require Platform Toolkit to be fully initialized. Console.WriteLine("Platform Toolkit has been initialized."); } public void Unsubscribe() { PlatformToolkit.Initialized -= OnPlatformToolkitInitialized; } } ``` -------------------------------- ### Set Implementation for BuildTarget in C# Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.Editor.PlatformToolkitEditor Configures a specific Platform Toolkit implementation for a given Unity BuildTarget. Overwrites any existing configuration for the specified build target. It takes the build target and the implementation key as input and returns a boolean indicating success. ```csharp public static bool SetImplementation(BuildTarget buildTarget, string key){ } ``` -------------------------------- ### Access Primary Account Information Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/manual/accounts/retrieve-account-information Demonstrates the essential C# code to access the primary user account. It includes error handling for user refusal and temporary unavailability exceptions. This is the minimum code required to establish a connection to the account. ```csharp try { if (PlatformToolkit.Capabilities.PrimaryAccount) { IAccount account = await PlatformToolkit.Accounts.Primary.Establish(); } } catch (UserRefusalException e) { // User refused to sign in } catch (TemporarilyUnavailableException e) { // Either a network error or sign in limit was exceeded } ``` -------------------------------- ### Accessing Local Saving System via IPlatformToolkit Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.IPlatformToolkit Illustrates how to obtain the ISavingSystem for local data persistence. This property may throw an InvalidOperationException if the platform does not support local saving. ```csharp try { // Assuming 'platformToolkit' is an instance of IPlatformToolkit ISavingSystem savingSystem = platformToolkit.LocalSavingSystem; // Use savingSystem for local data operations } catch (InvalidOperationException ex) { // Handle cases where local saving is not supported Debug.LogError("Local saving system not supported on this platform."); } ``` -------------------------------- ### React to Primary Account Sign Out Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/manual/accounts/retrieve-account-information Demonstrates a C# implementation within an account change callback to detect when the primary account signs out. It shows a common pattern of returning to the title screen upon sign-out. ```csharp private void Accounts_OnChange(IAccount account, AccountState newState) { if (account == myPrimaryAccount && newState == AccountState.SignedOut) // back to the title screen... } ``` -------------------------------- ### Show Account Picker Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.IAccountPickerSystem Displays a system prompt allowing users to sign in or select an existing account. This method returns a Task that resolves with the selected IAccount upon successful selection, or throws a UserRefusalException if the user cancels the prompt. ```APIDOC ## POST /api/accountpicker/show ### Description Shows a system prompt for signing in or selecting an account. ### Method POST ### Endpoint /api/accountpicker/show ### Parameters #### Query Parameters None #### Request Body None ### Request Example ```json {} ``` ### Response #### Success Response (200) - **IAccount** (Task) - Task which represents the lifetime of the account picker prompt. TResult contains the selected IAccount. #### Response Example ```json { "accountId": "user123", "displayName": "John Doe" } ``` ### Errors - **UserRefusalException** - User has canceled the account picker prompt. ``` -------------------------------- ### Initialize Achievement System (C#) Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/manual/achievements/unlock-achievements Initializes the achievement system by checking for account achievement capabilities and retrieving the achievement system instance. Handles `InvalidAccountException` for signed-out accounts. Requires the Platform Toolkit library. ```csharp if (PlatformToolkit.Capabilities.AccountAchievements) { try { IAchievementSystem achievementSystem; achievementSystem = await account.GetAchievementSystem(); } catch (InvalidAccountException e) { // Handle signed out account } } ``` -------------------------------- ### Key Property (C#) Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.Editor.PlatformToolkitEditor.PlatformToolkitImplementationInfo Provides a unique identifier for the Platform Toolkit implementation. This key is crucial for programmatic access and configuration management, allowing developers to reference specific toolkits when setting up project configurations. ```csharp public string Key { get; } ``` -------------------------------- ### Access Account Saving System Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/manual/accounts/retrieve-account-information Illustrates how to obtain the saving system associated with a user account using C#. This method is asynchronous and provides access to account-specific save data management. ```csharp var savingSystem = await account.GetSavingSystem(); ``` -------------------------------- ### C# IPrimaryAccountSystem Interface Definition Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.IPrimaryAccountSystem Defines the IPrimaryAccountSystem interface, which grants access to primary account functionalities. It specifies properties like 'Current' and methods such as 'Establish()', along with an 'OnChange' event for account status notifications. ```csharp namespace Unity.PlatformToolkit { public interface IPrimaryAccountSystem { IAccount Current { get; } Task Establish(); event Action OnChange; } } ``` -------------------------------- ### Enumerate Files in Save (C#) Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.ISaveReadable This method retrieves a list of all file names present within the save. It returns a Task that completes with an IReadOnlyList of strings, where each string is a file name. Potential exceptions include IOExceptions and errors related to account or system validity. ```csharp Task> EnumerateFiles() ``` -------------------------------- ### Access Platform-Specific or Local Save System (C#) Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/manual/savedata/access-save-system This code snippet demonstrates how to access a platform-specific saving system, prioritizing user accounts. If account capabilities are not available, it falls back to using the local saving system. It handles potential InvalidAccountExceptions. Dependencies include the PlatformToolkit and account-related functionalities. ```csharp ISavingSystem savingSystem; if (PlatformToolkit.Capabilities.Accounts) { try { savingSystem = await account.GetSavingSystem(); } catch (InvalidAccountException e) { // Handle signed out account } } else if (PlatformToolkit.Capabilities.LocalSaving) { savingSystem = PlatformToolkit.LocalSaving; } ``` -------------------------------- ### Initialize Primary Account and Access Save System (C#) Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/manual/accounts/handle-platform-account-systems Initializes the primary account and enables access to its saving system for platforms requiring mandatory accounts. It handles potential UserRefusalException and InvalidAccountException, common on console platforms. ```csharp await PlatformToolkit.Initialize(); // The following example assumes that the target platform has primary account functionality. While some platforms can be // configured to function without a primary account, these modes are meant for advanced // use cases, which are supported but not recommended for the vast majority of games. // EstablishLimited being false indicates that PlatformToolkit.Accounts.Primary.Establish() // can be called as many times as needed. This is typical of consoles and platforms where // an account is always signed in. if (PlatformToolkit.Capabilities.PrimaryAccountEstablishLimited is false) { try { // Attempt to get or sign in the primary account. var primaryAccount = await PlatformToolkit.Accounts.Primary.Establish(); // Get the primary account saving system. var savingSystem = await primaryAccount.GetSavingSystem(); } catch (UserRefusalException) { // UserRefusalException indicates that the player was presented with a sign-in // dialogue, which they then dismissed without signing in. Because EstablishLimited // capability is false, it's safe to call Establish() again until a player signs in. // This is typically done in the game's title screen, where the player is asked to // Press A or something similar. } catch (InvalidAccountException) { // InvalidAccountException indicates that account was signed out before // GetSavingSystem() method completed. You should always expect that any operation // on an IAccount object or any of its systems can fail in this manner, since on // many platforms players can sign out at any time. When this happens it's // recommended to return back to the title screen. } } ``` -------------------------------- ### Write a Save File Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/manual/savedata/manage-save-files Demonstrates the process of writing to a save file using the commit mechanism. This ensures atomic operations, guaranteeing that either all changes are written successfully or none are. ```APIDOC ## Write a Save File You can't write directly to save files. Instead, the save system uses a commit mechanism that treats each save as a complete snapshot. This process guarantees that no partial writes can occur. To write to a save file: * Open the save. This prepares a new version of the save without modifying the existing one. * Change any number of files. Add, update, or remove the binary data you need to save. * Commit the changes. The commit is an atomic operation. This means that either all your changes are written successfully, or none of them are. If the commit operation fails for any reason, the save file reverts to its original state, keeping your save data safe and preventing files from going out of sync. **Note**: Commits must contain at least one file. Committing an empty save, or deleting all files from an existing save, will cause the commit to fail. ### Request Example ```csharp byte[] characterStateData = null, storeStateData = null; try { await using ISaveWritable saveWritable = await savingSystem.OpenSaveWritable("my-save-file"); await saveWritable.WriteFile("character-state", characterStateData); await saveWritable.WriteFile("store-state", storeStateData); await saveWritable.Commit(); } catch (InvalidAccountException e) { // Handle signed out account } catch (NotEnoughSpaceException e) { // Prompt user that there is not enough space to write a save } catch (IOException e) { // Prompt user that saving has failed } ``` **Note**: Platforms might have different size limitations and capabilities when creating save files. It's recommended to refer to the providers platform-specific documentation for more information. ``` -------------------------------- ### Handle Save File Exceptions in C# Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/manual/savedata/manage-save-files This C# code snippet shows how to safely read and write save files using Unity's saving system. It includes comprehensive error handling for various exceptions such as invalid accounts, system issues, insufficient disk space, and corrupted save data. The code uses `async`/`await` for asynchronous operations and `using` statements for resource management. ```csharp try { await using (var writeable = await savingSystem.OpenSaveWritable("save-name")) { await writeable.WriteFile("filename", System.Text.Encoding.ASCII.GetBytes("important save file data")); await writeable.Commit(); } await using (var readable = await savingSystem.OpenSaveReadable("save-name")) { var reading = await readable.ReadFile("filename"); } } catch (InvalidAccountException) { // Handle account-related saving system invalidation. } catch (InvalidSystemException) { // Handle general saving system invalidation. } catch (NotEnoughSpaceException) { // Handle insufficient storage space for saving. } catch (SaveCorruptException) { // Handle corrupted save file detection. } ``` -------------------------------- ### DataStore API Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/manual/savedata/manage-save-files Introduces the `Unity.PlatformToolkit.DataStore` API for simplified saving and loading of game data without manual serialization. It supports basic data types like string, int, and float using a key-value system. ```APIDOC ## DataStore The DataStore API, `Unity.PlatformToolkit.DataStore`, provides a simple method for saving game data. The DataStore API allows you to read and write save data without serializing data into a byte array. It uses a key-value pair system, which allows you to store and retrieve data using a unique string key for each value. The DataStore supports the following basic data types: * `string` * `int` * `float` For more information, refer to the DataStore Scripting API reference. ### Request Example ```csharp try { ISavingSystem savingSystem = await account.GetSavingSystem(); DataStore dataStore = await DataStore.Load(savingSystem, "save-slot-1"); dataStore.SetInt("cheese", 99); dataStore.SetString("alias", "Cool Rat"); dataStore.GetFloat("cat-ratio", 0.56f); await dataStore.Save(savingSystem, "save-slot-1"); } catch (InvalidAccountException e) { // Handle signed out account } ``` ``` -------------------------------- ### TemporarilyUnavailableException Constructors Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.TemporarilyUnavailableException Documentation for the constructors of the TemporarilyUnavailableException class. ```APIDOC ## Constructors ### TemporarilyUnavailableException() Construct a TemporarilyUnavailableException with no message. #### Declaration ```csharp public TemporarilyUnavailableException() ``` ### TemporarilyUnavailableException(string message) Construct a TemporarilyUnavailableException with a message. #### Declaration ```csharp public TemporarilyUnavailableException(string message) ``` #### Parameters | Type | Name | Description | |--------|---------|--------------------------------| | string | message | The message to include with the exception. | ### Implements ISerializable ``` -------------------------------- ### PlatformToolkitImplementationInfo Class Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.Editor.PlatformToolkitEditor.PlatformToolkitImplementationInfo Represents information about an available Platform Toolkit implementation, including its display name, unique identifier, and supported platforms. ```APIDOC ## Class PlatformToolkitEditor.PlatformToolkitImplementationInfo ### Description Represents information about an available Platform Toolkit implementation. ### Namespace Unity.PlatformToolkit.Editor ### Assembly Unity.PlatformToolkit.Editor.dll ### Properties #### DisplayName **Type:** string **Description:** The display name for this Platform Toolkit implementation, as shown in the Unity Editor UI. #### Key **Type:** string **Description:** The unique identifier for this Platform Toolkit implementation. This key is used when setting configurations. #### SupportedPlatforms **Type:** IReadOnlyCollection **Description:** A read-only collection of Unity BuildTarget that this Platform Toolkit implementation supports. ``` -------------------------------- ### Read a Save File Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/manual/savedata/manage-save-files Illustrates the process of reading data from a save file. It includes error handling for corrupted saves and general I/O errors. ```APIDOC ## Read a Save File The following example describes the process of reading a save file. ### Request Example ```csharp try { if (!await savingSystem.SaveExists("my-save-file")) { // Handle save not existing } await using ISaveReadable saveReadable = await savingSystem.OpenSaveReadable("my-save-file"); byte[] characterStateData = await saveReadable.ReadFile("character-state"); byte[] storeStateData = await saveReadable.ReadFile("store-state"); } catch (CorruptedSaveException e) { // Delete the save } catch (IOException e) { // Prompt user that saving has failed } ``` ``` -------------------------------- ### C# Subscribe to IAccountSystem OnChange Event Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.IAccountSystem This code demonstrates how to subscribe to the OnChange event of the IAccountSystem. The event is invoked when an account signs in or out, providing the changed account and its new state. ```csharp using Unity.PlatformToolkit; public class AccountManager { private IAccountSystem accountSystem; public AccountManager(IAccountSystem system) { accountSystem = system; accountSystem.OnChange += HandleAccountChange; } private void HandleAccountChange(IAccount account, AccountState state) { UnityEngine.Debug.Log($"Account changed: ID {account.Id}, New State: {state}"); // Update UI or perform other actions based on the account state change } public void Cleanup() { accountSystem.OnChange -= HandleAccountChange; } } ``` -------------------------------- ### Access Local Saving System Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.PlatformToolkit Retrieves the ISavingSystem for local data storage. It's recommended to use the account-based saving system when available, falling back to local saving only if the account system is unavailable. Use this property to check if the current platform supports local saving. ```csharp using Unity.PlatformToolkit; public class SaveDataHandler { public void SaveLocally() { ISavingSystem localSaving = PlatformToolkit.LocalSaving; if (localSaving != null) { // Save data locally. } else { // Local saving is not supported. } } } ``` -------------------------------- ### IInputDevice Interface Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.IInputDevice This section describes the IInputDevice interface, which is used for referring to platform devices as part of input ownership within the Unity Platform Toolkit. ```APIDOC ## Interface IInputDevice ### Description Interface for referring to platform devices used as part of input ownership. ### Namespace Unity.PlatformToolkit ### Assembly Unity.PlatformToolkit.dll ### Syntax ```csharp public interface IInputDevice ``` ### Properties #### Id Platform specific and input system agnostic id. ##### Declaration ```csharp string Id { get; } ``` ##### Property Value - **Type**: string - **Description**: Platform specific and input system agnostic identifier for the input device. #### IdType Platform can support different types of Id for input devices. ##### Declaration ```csharp string IdType { get; } ``` ##### Property Value - **Type**: string - **Description**: Indicates the type of identifier used for the input device by the platform. ``` -------------------------------- ### Enumerate Saves Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/manual/savedata/manage-save-files Explains how to list available save files using the `EnumerateSaves` method, which is useful for displaying options in a save menu. Note that saves can only be enumerated when no save files are currently open. ```APIDOC ## Enumerating Saves To display a list of available save files to the player, such as in a save menu, you can use the EnumerateSaves method. EnumerateSaves returns a list of the existing save names within a save system. You can access a save system from an account or use a local save system. For more information, refer to Access a save system. **Note**: Saves can only be enumerated when no save files are currently open. If a save file is open, an `InvalidOperationException` is thrown. ``` -------------------------------- ### Manage Optional Accounts and Use Local Save System (C#) Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/manual/accounts/handle-platform-account-systems Modifies account handling for platforms where user accounts are optional, like mobile. It uses the local saving system when an account isn't available and allows for later sign-in. Handles UserRefusalException, TemporarilyUnavailableException, and InvalidAccountException. ```csharp await PlatformToolkit.Initialize(); // EstablishLimited being true indicates that PlatformToolkit.Accounts.Primary.Establish() // can be disallowed by the operating system, meaning that there can be times when account // sign-in is impossible. This is typical of mobile platforms, where use of an account is optional. if (PlatformToolkit.Capabilities.PrimaryAccountEstablishLimited is true) { try { // Attempt to get or sign in the primary account. var primaryAccount = await PlatformToolkit.Accounts.Primary.Establish(); // Get the primary account saving system. var savingSystem = await primaryAccount.GetSavingSystem(); } catch (Exception e) when (e is UserRefusalException or TemporarilyUnavailableException) { // When EstablishLimited capability is true and Establish() throws either // UserRefusalException or TemporarilyUnavailableException, it's recommended to // proceed without an account and use the local saving system instead. In order to // allow players to sign in later a Sign In button should be added somewhere in // the game. Pressing that button would then call Establish() again. if (PlatformToolkit.Capabilities.LocalSaving) { var savingSystem = PlatformToolkit.LocalSaving; } else { // Not currently possible as all platforms that have EstablishLimited // capability support the local saving system. } } catch (InvalidAccountException) { // InvalidAccountException indicates that account was signed out before // GetSavingSystem() method completed. } } ``` -------------------------------- ### C# Interface IInputDevice Definition Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.IInputDevice Defines the IInputDevice interface within the Unity.PlatformToolkit namespace. This interface is intended for referring to platform devices used for input ownership and specifies properties for device identification. ```csharp namespace Unity.PlatformToolkit { public interface IInputDevice { string Id { get; } string IdType { get; } } } ``` -------------------------------- ### Read File from Save (C#) Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.ISaveReadable This method reads the data from a specified file within the save. It returns a Task that completes with a byte array containing the file's data. Exceptions can occur if the file is not found, the save is corrupted, or due to IO or account/system issues. ```csharp Task ReadFile(string name) ``` -------------------------------- ### IPlatformToolkit Interface Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.IPlatformToolkit The main interface for accessing platform-specific services. It provides properties for account management, capabilities, and local saving. ```APIDOC ## Interface IPlatformToolkit ### Description Platform Toolkit implementation. Accessed through PlatformToolkit class. ### Namespace Unity.PlatformToolkit ### Assembly Unity.PlatformToolkit.dll ### Syntax ```csharp public interface IPlatformToolkit ``` ### Properties #### Accounts Get the IAccountSystem. Exposed through Accounts. ##### Declaration ```csharp IAccountSystem Accounts { get; } ``` ##### Property Value - **Type**: IAccountSystem - **Description**: Provides access to account management functionalities. #### Capabilities Get the ICapabilities. Exposed through Capabilities. ##### Declaration ```csharp ICapabilities Capabilities { get; } ``` ##### Property Value - **Type**: ICapabilities - **Description**: Provides access to device and platform capabilities. #### LocalSavingSystem Get the local saving system on platforms that support it. ##### Declaration ```csharp ISavingSystem LocalSavingSystem { get; } ``` ##### Property Value - **Type**: ISavingSystem - **Description**: Provides access to the local saving system. ##### Exceptions - **Type**: InvalidOperationException - **Condition**: Thrown when the platform does not support the local saving system. ### Methods #### Initialize() Platform-specific initialization method. ##### Declaration ```csharp Task Initialize() ``` ##### Returns - **Type**: Task - **Description**: Task that returns when completed. ``` -------------------------------- ### Unity C# DataStore GetString Methods Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.DataStore Retrieves a string value associated with a given key. Overloads allow specifying a default value to return if the key does not exist. These methods are used to access stored text data. ```csharp public string GetString(string key) { // Implementation to get string value, returning default if not found } public string GetString(string key, string defaultValue) { // Implementation to get string value with a specified default } ``` -------------------------------- ### Save Data with ISavingSystem in Unity Platform Toolkit Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.DataStore Saves a DataStore object to a specified ISavingSystem. This operation may throw exceptions related to invalid arguments, insufficient space, I/O errors, or account/system issues. It returns a Task that completes upon successful saving. ```csharp public Task Save(ISavingSystem savingSystem, string saveName) { // Implementation details for saving data return Task.CompletedTask; } ``` -------------------------------- ### Access Capabilities Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.PlatformToolkit Provides access to the capabilities of the current platform through the ICapabilities interface. This allows developers to query and utilize platform-specific features. ```csharp using Unity.PlatformToolkit; public class CapabilityChecker { public void CheckPlatformCapabilities() { ICapabilities capabilities = PlatformToolkit.Capabilities; // Use capabilities to check for specific platform features. } } ``` -------------------------------- ### Access Account System Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.PlatformToolkit Retrieves the IAccountSystem interface for managing user accounts. This property can throw an InvalidOperationException if accounts are not supported on the current platform, if Initialize() has not been called or completed, or if the Accounts property is null. ```csharp using Unity.PlatformToolkit; public class AccountManager { public void CheckAccountSupport() { try { IAccountSystem accounts = PlatformToolkit.Accounts; if (accounts != null) { // Account system is supported and available. } } catch (InvalidOperationException) { // Accounts are not supported or not initialized. } } } ``` -------------------------------- ### IAccount GetSavingSystem Method Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.IAccount Obtains the ISavingSystem for the account, which manages saving operations specific to that account. This may involve long-running operations and can throw various exceptions. ```csharp Task GetSavingSystem(); ``` -------------------------------- ### SignOut Method Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.IAccount Manually signs out an account. This method can be used to initiate a sign-out process for a given account. ```APIDOC ## POST /websites/unity3d_packages_com_unity_platformtoolkit_1_0/SignOut ### Description Manually signs out an account. Use AccountManualSignOut for a given account type to check if sign out is supported. ### Method POST ### Endpoint /websites/unity3d_packages_com_unity_platformtoolkit_1_0/SignOut ### Parameters #### Query Parameters - **attributeName** (string) - Required - Name of the attribute. ### Request Example ```json { "attributeName": "exampleAttribute" } ``` ### Response #### Success Response (200) - **Task** (Task) - A Task containing a result of the sign out. #### Response Example ```json { "Result": true } ``` ### Exceptions - **InvalidOperationException**: Sign out isn't supported as indicated by ICapabilities. - **InvalidAccountException**: IAccount is signed out. ``` -------------------------------- ### PlatformToolkitImplementationInfo Class Definition (C#) Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.Editor.PlatformToolkitEditor.PlatformToolkitImplementationInfo Defines the PlatformToolkitImplementationInfo class within the Unity.PlatformToolkit.Editor namespace. This class holds information about a specific Platform Toolkit implementation, including its display name, unique key, and supported build targets. ```csharp public class PlatformToolkitEditor.PlatformToolkitImplementationInfo { // Properties are defined below } ``` -------------------------------- ### Writing Data to a File using ISaveWritable Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.ISaveWritable The WriteFile method allows you to write byte data to a specified file within a save. If the file exists, it will be overwritten; if not, it will be created. This operation can be canceled out by a subsequent DeleteFile call. ```csharp Task WriteFile(string name, byte[] data) ``` -------------------------------- ### Register Input Device Converter - C# Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.IInputOwnershipSystem Registers a converter function to translate input system-specific input devices into platform-specific IInputDevice types. This is useful for custom input device implementations, allowing the system to correctly identify and manage ownership for them. ```csharp void RegisterInputDeviceConverter(Func converter) where T : IInputDevice; ``` -------------------------------- ### Retrieve Account Data (Name) Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/manual/accounts/retrieve-account-information Shows how to use the IAccount API in C# to retrieve specific account details, such as the player's username. This function is asynchronous and returns the name once available. ```csharp var name = await account.GetName(); ``` -------------------------------- ### Unity C# DataStore Class Definition Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.DataStore Defines the DataStore class within the Unity.PlatformToolkit namespace. This class is used for storing string, float, and integer values that can be saved and loaded via an ISavingSystem. Changes are local until explicitly saved. ```csharp public class DataStore { // Methods for Create, DeleteAll, DeleteKey, GetFloat, GetInt, GetString, HasKey, Load } ``` -------------------------------- ### C# IPrimaryAccountSystem.OnChange Event Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.IPrimaryAccountSystem An event that is invoked when the primary account changes. This allows developers to react to changes in the primary account status, which can be platform-dependent. ```csharp /// /// Invoked after primary account changes. /// event Action OnChange; ``` -------------------------------- ### Unity C# DataStore GetFloat Methods Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.DataStore Retrieves a float value associated with a given key. Overloads allow specifying a default value to return if the key does not exist. These methods are used to access stored floating-point numbers. ```csharp public float GetFloat(string key) { // Implementation to get float value, returning default if not found } public float GetFloat(string key, float defaultValue) { // Implementation to get float value with a specified default } ``` -------------------------------- ### TemporarilyUnavailableException Class Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.TemporarilyUnavailableException Details about the TemporarilyUnavailableException class, including its purpose, inheritance, and namespace. ```APIDOC ## Class TemporarilyUnavailableException Thrown when an operation failed due to some temporary state, like no network connection. ### Inheritance object Exception SystemException IOException TemporarilyUnavailableException ### Implements ISerializable ### Inherited Members Exception.GetBaseException() Exception.GetObjectData(SerializationInfo, StreamingContext) Exception.GetType() Exception.ToString() Exception.Data Exception.HelpLink Exception.HResult Exception.InnerException Exception.Message Exception.Source Exception.StackTrace Exception.TargetSite Exception.SerializeObjectState object.Equals(object) object.Equals(object, object) object.GetHashCode() object.MemberwiseClone() object.ReferenceEquals(object, object) ### Namespace Unity.PlatformToolkit ### Assembly Unity.PlatformToolkit.dll ### Syntax ```csharp public class TemporarilyUnavailableException : IOException, ISerializable ``` ``` -------------------------------- ### DisplayName Property (C#) Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.Editor.PlatformToolkitEditor.PlatformToolkitImplementationInfo Represents the user-facing name of the Platform Toolkit implementation. This string is displayed in the Unity Editor's user interface, allowing users to easily identify different toolkit options. ```csharp public string DisplayName { get; } ``` -------------------------------- ### Unity C# DataStore DeleteAll Method Source: https://docs.unity3d.com/Packages/com.unity.platformtoolkit@1.0/Packages/com.unity.platformtoolkit%401.0/api/Unity.PlatformToolkit.DataStore Removes all key-value pairs from the DataStore. This operation is local and does not affect any associated image data. It resets the DataStore to an empty state. ```csharp public void DeleteAll() { // Implementation to clear all keys and values } ```