OnItemPickup Events

MarkusKer

Member
Hello,

i am trying to add events to the item pickup. for example if i pickup a item i would like a number of tasks to run via the unity eventsystem. As far as i can tell it would be pretty easy executing an invoke in the "ItemPickupBase" or "ItemPickup" Scripts. Unfortunaletty i am not able to add another public variable to either of the scripts. I tried to add an serializable unity event to both of the scripts but they down show up exposed in the editor.

How would i have to declare a new variable to show up and where would i have to put it in the script?

Regards,
Markus
 
There are corresponding Inspector classes which do the drawings for those scripts. ItemPickupBaseInspector, ItemPickupInspector.
 
I tried adding the following lines to both of the scripts but it did not show up in the editor. I think i am missing out on a crucial part of doing this the right way.
1612213793494.png
 
Those components use custom inspectors, so you need to modify their relevant inspector scripts to make any variables show up in the inspector. E.g. if you're modifying ItemPickupBase, then you'd need to modify ItemPickupBaseInspector. I'd recommend reading a guide about custom inspectors.

You may want to create your own subclass of ItemPickupBase and ItemPickupBaseInspector, that way you can just inherit the inspector's OnInspectorGUI method and add any additional fields you need, rather than needing to modify the base class directly which might get messy/confusing (and any changes you make might get overwritten when updating UCC in the future).
 
Top