Changing inventory identifier at runtime

ChristianWiele

Active member
Hi,

I would like to set the inventory identifier at runtime / after intantiation. The InventoryIdentifier class has public properties for that, but not methods to register the changed identifier. This is only done during awake. Can you add a method to register the identifier at runtime?

Thanks, Christian
 
Here is a new Inventory Identifier. I made a register and Unregister function public. This way you can register and unregister it whenever you want.
Let me know if that works for you
 

Attachments

  • InventoryIdentifier.cs
    2.9 KB · Views: 2
Thanks a lot, I will try this. Just one idea. Wouldn't it be better to handle the register/unregister internally through the ID setter? So, whenever the ID changes, it automatically unregisters the old ID, and registers the new one?
 
That doesn't seem to work. I get an error "Cannot change the ID ..." from line 208 of the InventoryObjectRegister<T> class.
 
When I first designed Inventory Identifier I thought about making it such that the ID would never change. But I understand how that can be limiting.
Here is an update version, I make it inherit from IObjectWithID instead of IObjectWithIDReadOnly

Let me know if that works
 

Attachments

  • InventoryIdentifier.cs
    3.3 KB · Views: 5
Top