Comment on page


GameLootBox is used at runtime, and should be added to any object that has a LootBox. It implements IHaveInventory and IHaveDictionaries. Unlike other Game[Object] scripts, this one is a Monobehaviour.
Do not modify this script, so that if we update the Game Modules in the future, you will not find your code overwritten. Instead, use the instructions in this documentation to override and otherwise modify the methods.
(This goes for all the scripts, of course)
You will likely need to create your own GameLootBox script which inherits from GameLootBox. This will allow you to override the methods and customize how Loot is generated, and how to handle the loot.
Learn more on the Generating & Handling Loot page.
When you add GameLootBox, or a class that you created which inherits from GameLootBox, there are a few variables in the Inspector to pay attention to.
The Loot Box Uid is empty by default. You'll need to populate that.
The Game Id is automatically generated. This is a unique in-game identifier for this GameLootBox. No two Game Id values should be the same.
The "Generate On Awake" toggle determines whether the contents of the GameLootBox generate on Awake() or later, when you specifically tell it to generate. You may wish to delay generation if there are a lot of GameLootBoxes in your scene, or if in-game parameters, such as a players stats, may affect the content generated.
You will need to popualte the Loot Box Uid. To do this, bring up the LootBox object you'd like to use in the Inspector, and click the "Copy Uid" button by the Uid, at the top of the window.
The Uid on the LootBox scriptable object can be used in many GameLootBoxes.
Don't forget to add a Saveable component to your object as well, or the values will not be saved, including whether the loot has been generated.
If your LootBox can hold inventory too, like a physical box, the contents would be lost if Saveable is not added to the object.