Class DataPersistenceSample
This class manages the scene for showcasing the data persistence sample.
Inherited Members
Namespace: UnityEngine.GameFoundation.Sample
Syntax
public class DataPersistenceSample : MonoBehaviour
Fields
gameFoundationInit
Reference in the scene to the Game Foundation Init component.
Declaration
public GameFoundationInit gameFoundationInit
Field Value
Type | Description |
---|---|
GameFoundationInit |
mainText
We will need a reference to the main text box in the scene so we can easily modify it.
Declaration
public Text mainText
Field Value
Type | Description |
---|---|
Text |
Methods
AddHealthPotion()
Adds a health potion item to the inventory manager. The health potion Inventory Item first needs to be set up in the Inventory window.
Declaration
public void AddHealthPotion()
AddNewSword()
Adds a new sword item to the GameFoundationSdk.inventory. The sword Inventory Item first needs to be set up in the Inventory window.
Declaration
public void AddNewSword()
Load()
This will un-initialize game foundation and re-initialize it with data from the save file. This will set the current state of inventories and properties to be what's within the save file.
Declaration
public void Load()
OnGameFoundationException(Exception)
If GameFoundation throws exception, log the error to console.
Declaration
public void OnGameFoundationException(Exception exception)
Parameters
Type | Name | Description |
---|---|---|
Exception | exception | Exception thrown by GameFoundation. |
OnGameFoundationInitialized()
Once Game Foundation completes initialization, we enable buttons, setup callbacks, update GUI, etc.
Declaration
public void OnGameFoundationInitialized()
RemoveAllItems()
Removes all Inventory Items from GameFoundationSdk.inventory.
Declaration
public void RemoveAllItems()
Save()
This will save game foundation's data as a JSON file on your machine. This data will persist between play sessions. This sample only showcases inventories, but this method saves their items, and properties too.
Declaration
public void Save()