Game Foundation
Introduction
During game development, there are many basic gameplay systems that are common to most games. Developers have to take the time to build and rebuild these systems when they really want to focus on what’s unique and fun.
Game Foundation provides pre-built common game systems that are flexible and fully extensible so that developers can focus on building unique gameplay.
Please see Getting Started for more detailed information. A brief summary is provided below.
Getting Started
Installing the Package
In order to use Game Foundation in your game, you’ll first have to install the package.
From Unity package registry
- Open the Package Manager (Window → Package Manager).
- Make sure preview packages are enabled (Advanced → Show preview packages).
- Find Game Foundation in the left column and select it.
- Click the
Install
button (in the lower right or upper right, depending on your Unity version).
From manually downloaded package
If you are using a manually downloaded package it will not appear in the Package Manager UI and should be installed as follows:
- Extract the archive to a new directory
- Open the Package Manager (Window → Package Manager).
- In Package Manager UI select the
+
button (either upper left or bottom right corner) and thenAdd package from disk...
- Navigate to your extracted archive and select the
package.json
file
After installing the package, you’ll have some new menu items tied to editor windows.
Game Systems Overview
Inventory
An inventory is a way of keeping track of a collection of items, as well as how many of those items exist in that collection. Some basic examples of inventories would be a backpack or a chest. But you could also think of other collections of items as inventories as well. For example, when loot is sitting on the ground, maybe it’s contained in the ‘ground’ inventory. If a sword has boosting gems installed in it, then you could say that sword has an inventory and the gems are contained in it.
Inventories will have a runtime instance and a definition.
Game Foundation automatically creates a ‘main’ inventory by default, so you don’t need to define and create more inventories if you don’t need more than one.
Wallet
The Wallet is a special variation of inventory which only contains currencies. A common example for using a wallet is in casual mobile games where the player can accumulate one or more types of currency, such as coins, gems, etc. A default wallet is automatically created, and you can access and manage that default wallet conveniently with the Wallet class.
Stat
With stats, you can track and manage numeric values used in the game, such as the health of the player’s character and enemies, weapon damage, tool durability, a consumable item’s healing amount, buff amount, etc. Extending the stat system will allow you to apply formulae to stats based on modifiers and player progression.
The numeric types currently supported are Float (System.Single) and Int (System.Int32). Once you choose which numeric type a stat is, it cannot be changed later.
Runtime Persistence
With runtime persistence, you can save the state of the game to a local file, and then load it up again at a later time.
Analytics
This system lets you easily record data points generated by users of your game. You can then analyze the data in order to improve things like gameplay balance and IAP conversion. You can enable or disable Analytics in the Game Foundation settings.