Comment on page
GameLootBoxis used at runtime, and should be added to any object that has a
LootBox. It implements
IHaveDictionaries. Unlike other Game[Object] scripts, this one is a
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
GameLootBoxscript which inherits from
GameLootBox. This will allow you to override the methods and customize how Loot is generated, and how to handle the loot.
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
Awake()or later, when you specifically tell it to generate. You may wish to delay generation if there are a lot of
GameLootBoxesin 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
LootBoxscriptable object can be used in many
Don't forget to add a
Saveablecomponent to your object as well, or the values will not be saved, including whether the loot has been generated.
LootBoxcan hold inventory too, like a physical box, the contents would be lost if
Saveableis not added to the object.