ItemObject script question

The item Object stores a ItemInfo.
The Item Info is a struct, it has the information about the Item, Amout, and optionally the ItemCollection, and Inventory where the item is stored

So something like this should work:
Code:
itemObject.ItemInfo.Amount

I'll add an Amount property in the next update to make it easier.

If you wish to set the amount, you'll have the set a new ItemInfo using the SetItem or SetAmount function
 
I thought that would have worked too, but the following is still just returning 1 (when it should be 10 based on the image above):

Code:
Debug.Log(this.GetComponent<ItemObject>().ItemInfo.Amount);

Anything else to try?
 
Are you sure you are referencing the correct ItemObject?
Look at the inspector at runtime, perhaps something else has set the amount to 1 before your debug.log was called.
 
Yeah, ItemObject and ItemPickup (which is the script with the Debug line in it) are both on the same gameobject. And the inspector shows 10 as well. When I pick up the item, the correct number (10 in this case) goes into my inventory. What else could I be looking for?
 
At what point are you calling that Debug.Log? Perhaps you are calling debug before the ItemObject fields was deserialized?
This happens on Start of the Item Object class when SetItem(itemInfo) is called.

I would recommend you listen to the on change event to know the correct value of the item (or amount) when it changes
Code:
EventHandler.RegisterEvent(m_ItemObject, EventNames.c_ItemObject_OnItemChanged, HandleItemObjectItemChanged);
 
Top