No option to dynamically assign inventory to InventoryMonitor

ChristianWiele

Active member
Hi,

I would like to dynamically spawn my players, but the InventoryMonitor has no method to assign the inventory dynamically. The CurrencyOwnerMonitor and the DisplayPanelManager have corresponding methods to change/set the owner.

Regards, Christian
 
You are correct, I added this new function to assign an Inventory:

Code:
/// <summary>
/// Set the Inventory to monitor.
/// </summary>
/// <param name="monitoredInventory">The monitored Inventory.</param>
public void SetMonitoredInventory(Inventory monitoredInventory)
{
    if (isActiveAndEnabled) {
        StopListening();
        m_MonitoredInventory = monitoredInventory;
        StartListening();
    } else {
        m_MonitoredInventory = monitoredInventory;
    }
}

This should allow you to set the new inventory to monitor
 
I figured out that this fix is not sufficient. The problem is that some of the initialization in the Awake method is never run when there is no inventory assigned (everything beyond line 87). And even after assigning an inventory, there is no chance to run this code.
 
Good catch, I didn't think about that.
I moved a few things around. It should work now.
You can find the new script attached.
 

Attachments

  • InventoryMonitor.cs
    12.8 KB · Views: 1
Top