Unity Package

We provide a Unity package that wraps our Javascript API. It can be downloaded from the following URL:

Tutorial Game

We have additionally built an example game in the form of an interactive book meant to guide you in setting up the package and testing basic functionality of our API. After being given access to our developer portal, you should be able to access this tutorial by opening the following URL:

If you have the appropriate developer permissions and click on the book to open it, you should see the following:

Armor Games Unity API Tutorial

Make sure to follow the instructions on the initial setup pages including:

  • Downloading the most recent ag.min.js file.
  • Renaming the file to ag.min.jspre and move it to the Plugins folder (overwriting the one that came with the package).
  • Updating the api_key value on line 49 of the AGI.jslib to your game's api_key.

When going through the interactive tutorial, you can use the controls to the left of the game window to give yourself products (ie, unlockable and consumable products) or to see the status of quests.


The quests status and products do not automatically refresh based on interacting with the game (ie, if you consume a product or update a quest). Please refresh your browser window to see the latest state of these values.



All of the following documentation is also available as a README file in the package.

  • Firstly, to make AGI calls you'll need to ensure that you have placed the AGI prefab in your scene.
  • This is a premade GameObject that already has the AGIUnity.cs attached. No AGI GameObject, no AGI calls!
  • Using AGI with Unity is as simple as it gets using our example script!
  • All you need to do is copy the contents of the function you'd like from within AGIUnityExampleCalls.cs or reference the static function from within AGIUnity.cs.
  • On line 49 of ag.min.jspre, ensure you enter the correct api key for your game. Visit the developer portal to obtain this key from the game`s settings page.

AGIUnity.cs Usage

See the code snippets below for C# examples of static calls to various methods provided by our API:

// Log the user in and grant access to information including username, UID and avatar.
// To make use of this information, you must handle it in UnityAGI.cs (SetUsername, SetUID, 
// SetAvatar).

// Key is the name of the save, this could be called "highscore" if you are saving a users
// highscore. Here, a random number is saved for testing purposes.
AGIUnity.SaveData(key, Random.Range(10, 100));

// Key identifies the data to load, in our example, this is called "highscore".

// Erase a save with the given key. In our example, this is called "highscore".

// Add to your key. In this example, we would add 1 to the stored value.
AGIUnity.IncrementGame(key, 1);

// Subtract from your key. In this example, we would add 1 to the stored value.
AGIUnity.DecrementGame(key, 1);

// GetQuests retrieves any active quests for the user.
// The quests in the array must be handled one at a time from the QuestRetrieved function
// in AGIUnity.cs

// Submit quest progress for the user. Progress is a value from 0.0 to 1.0, with 1.0 being
// 100% complete for a specific Quest ID.
AGIUnity.SubmitQuest(s, 1);

// This is an example of how to submit a specific quest that we use in this demo.
AGIUnity.SubmitQuest("easy_quest", questValue);

// This is an example of how to submit a specific quest that we use in this demo.
AGIUnity.SubmitQuest("hard_quest", questValue);

// Resets a quest's progress back to zero using a Quest ID.

// Displays the HTML Storefront modal window atop the game.

// Retrieve all purchases made by the user. These must be handled in AGIUnity.cs

// The consume method will decrease a user's item quantity by the given amount for the 
// provided product SKU.
AGIUnity.ConsumePurchase(sku, 1);

// This will open a new tab in the users browser.

Package Contents

  • AGI.jslib script - These are JS functions that link to the original Armor Games AGI JS file.
  • Demo Example Scene - A premade Unity scene with basic usage of the AGI within Unity. It contains all files needed with buttons linking to common AGI calls and is a great way to start your journey!
  • AGIUnity.cs script - This handles the interactions with JavaScript from the AGI.jslib file. These are the functions you’re able to call upon within Unity.
  • AGIUnityExampleCalls - A script full of example functions that interact with the AGI. You can copy any of these functions to other scripts or use this class as it is.
  • AGSplashScreen - A prefab pre-set up with the Armor Game splash screen. Please ensure you have assigned your camera to the video player component.
  • AGI Prefab - A prefab containing the AGIUnity.cs script already. Place this in your game as early as possible before making AGI Calls.


Feel free to reach out to us at mygame@armorgames.com if you have any questions.