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 Awake method of a MonoBehaviour.
using UnityEngine;
using UnityEngine.GameFoundation;
public class MyGameManager : MonoBehaviour
{
void Awake()
{
// this data layer will not save any data, it is usually used for examples or tests
MemoryDataLayer dataLayer = new MemoryDataLayer();
// initialize Game Foundation for runtime access
GameFoundation.Initialize(dataLayer);
}
}
When you initialize Game Foundation, all managers, including InventoryManager, WalletManager, StatManager and TransactionManager will be initialized and ready to use.
- Tip: To verify that Game Foundation is working and installed correctly, please check the IsInitialized property on any Game Foundation manager.
using UnityEngine;
using UnityEngine.GameFoundation;
public class MyGameManager : MonoBehaviour
{
void Awake()
{
// this data layer will not save any data, it is usually used for examples or tests
MemoryDataLayer dataLayer = new MemoryDataLayer();
// initialize Game Foundation for runtime access
GameFoundation.Initialize(dataLayer);
// verify that the manager is initialized
if (InventoryManager.IsInitialized)
{
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
- Adding static properties with details
- Adding mutable properties with Stats
- Playing with stats at runtime
- Creating a Virtual Transaction
- Playing with virtual transaction at runtime
- Using IAP Transactions
- Filtering transactions with Stores
Also, please visit Known Issues if you need further assistance.