By default the Inventory Demos are setup such that both the player inventory and the UI are in the scene.
But in some cases you may which to spawn the UI or the character at different times after the scene is loaded.
The Managers (usually the “Game” gameobject) must be spawned before any other of the Inventory system related components. The managers are singletons which are referecend by many things in the system and without them loading first the other components will throw errors.
Loading UI first
If the Display Panel Manager is loaded before the player inventory it will wait until a panel owner is set to initialize. Meaning none of the panels will be initialized and they won’t be usable until a panel owner set.
The “Dynamic Panel Owner” component can be set on the Player prefab which is spawned a runtime. This will hookup the panel owner to the Display Panel Manager automatically.
This can also be done manually through code.
Loading Player first
Loading the Player before the UI will not require any additional changes. As soon as the UI is spawned the Display Panel Manager will find the player using the Inventory Identifier ID.
Of course the IDs must match. In local multiplayer each UI must have a matching unique ID to there player.
Loading the Player and UI at the same time
It is also possible to create a scene with just the player and the UI and load it additively.
Seperate the Inventory from the player
It is possible, in some cases, to split the Inventory from the Player gameobject. For example the player Inventory could be set in the Canvas. And the player gameobject could get a reference to it using the Inventory Identifier ID.
// Get an Inventory Identifier by ID (a component which sits next to an Inventory) var inventoryIdentifier = InventorySystemManager.GetInventoryIdentifier(id); var inventory = inventoryIdentifier.Inventory;
More code examples here
There are some limitations to this solution, for example the Inventory Interactor component won’t support it.
To learn more about scene transitions go here