Installing the Game Foundation package
In the Unity Editor, open the Package Manager window (menu: Window → Package Manager).
In the Package Manager window, click Advanced and make sure that Show preview packages is enabled.
In the list of packages on the left, find Game Foundation and select it.
In the upper-right (bottom-right on some versions of Unity), click on the Install button.
After installation, the Game Foundation menu items and editor windows are available in your Unity project in the Window menu.
Quick start
Before Game Foundation can be used during runtime, it has to be initialized in your code. The following is an example of initializing Game Foundation with the Start method of a MonoBehaviour.
using System.Collections;
using UnityEngine;
using UnityEngine.GameFoundation;
using UnityEngine.GameFoundation.DefaultLayers;
using UnityEngine.Promise;
public class MyGameManager : MonoBehaviour
{
IEnumerator Start()
{
// This data layer will not persist any data, it is usually used for examples or tests.
MemoryDataLayer dataLayer = new MemoryDataLayer();
// Initialize Game Foundation for runtime access.
Deferred initialization = GameFoundationSdk.Initialize(dataLayer);
yield return initialization.Wait();
// It optimizes the memory as it allows the object to be reused.
initialization.Release();
}
}
When you initialize Game Foundation, all managers, including InventoryManager
, WalletManager
and TransactionManager
will be initialized and ready to use.
- Tip: To verify that Game Foundation is working and installed correctly, please null-check any Game Foundation manager.
using System.Collections;
using UnityEngine;
using UnityEngine.GameFoundation;
using UnityEngine.GameFoundation.DefaultLayers;
using UnityEngine.Promise;
public class MyGameManager : MonoBehaviour
{
IEnumerator Start()
{
// This data layer will not persist any data, it is usually used for examples or tests.
MemoryDataLayer dataLayer = new MemoryDataLayer();
// Initialize Game Foundation for runtime access.
Deferred initialization = GameFoundationSdk.Initialize(dataLayer);
yield return initialization.Wait();
// It optimizes the memory as it allows the object to be reused.
initialization.Release();
// Verify that the manager is initialized.
if (GameFoundationSdk.inventory != null)
{
Debug.Log("Game Foundation is installed and ready!");
}
else
{
Debug.LogError("Error: Game Foundation was unable to initialize. Please check online help or docs for more information.");
}
}
}
After implementing the above code, when you press Play you will see that Game Foundation has been successfully installed and ready to build your game!
Now you can head over to one of our Tutorials for more information:
- Creating an Inventory Item Definition
- Playing with items at runtime
- Creating a Currency
- Playing with currencies at runtime
- The Debugger window
- Static Properties
- Mutable Properties Editor
- Playing with mutable properties at runtime
- Creating a Virtual Transaction
- Playing with virtual transaction at runtime
- Using IAP Transactions
- Filtering transactions with Stores
- Working with Store Prefabs
- Working with Promotion Popup Prefab
- Configure your game with parameters
Also, please visit Known Issues if you need further assistance.