PanelManager
v4.0
Last updated
v4.0
Last updated
The PanelManager
class manages the inventory panels during runtime. This is needed for games where there are up to two inventory panels active at once -- the player inventory panel, and potentially a "Other panel", which could be a treasure box or other object that has an inventory. This way, the user can easily navigate between the player inventory panel, the other panel, and transfer items back and forth.
This class is attached to the Prefab Inventory Module Requires Scripts
. Bring that into your project.
This is a static method, which you can utilize via this code at the top of your script:
The module assumes that there will be an "always on" inventory panel for the player. While this is not static by any means, and can display the inventory of various players, such as in a game where there are multiple player members of a party, the inventory panel is assumed to not be destroyed or instantiated at run time.
While technically optional, we expect most projects will make use of this.
This is the camera used to show the UI Inventory and canvas. This is set automatically by the PanelManager
class.
Inventory panels instantiated will be parented under this Rect Transform
.
When true, the Console will show Debug.Log
messages during key events. This is helpful if you want to better understand which methods are being called during your interaction with the Inventory module. It will toggle off automatically when not in the Unity Editor.
This will return whichever panel is active. It could be the player panel, or an "other" panel. Will return null
if there is no active panel.
This will return whichever panel is active. It could be the player panel, or an "other" panel. Will return null
if there is no active panel.
This will populate the otherPanel
with the newPanel
passed in, and optionally set the new panel to activate.
Use these methods to set the Player panel and the Other panel active. The other will turn off at the same time.
iHaveInventoryGameId
is the GameId of the object which will have its inventory displayed.