Reply To: EventSystem and Custom Events purpose?

Home Forums Books Unity 3D UI Essentials EventSystem and Custom Events purpose? Reply To: EventSystem and Custom Events purpose?


Now that takes me back, I did an entire example on this in my previous book.

For this example, the best answer would be to have a static property on the ShopManager than controls the ShopItemList , to have a property called Selected that is a type of ShopItem.

Then ensure that each ShopItem has a reference back to the ShopManager when it is instantiated.  Once the ShopItem receives the Click event, you set a bool in the ShopItem (selected) and also update the ShopManager SelectedItem property to the instance of the selected shop item. (I hope that makes sense)

This works so long as only one item in the shop can be selected at at a time.  So in that case the event system would be an overkill.


Now, if you could have multiple selected items, you could extend the above example to have static “AddSelectedShopItem” and “RemoveSelectedShopItem” methods on the manager and have a private list in the manager for selected items.


If you really wanted to use the EventSystem, then keep it simple and just use the UnityEvent setup as shown in the “Working with events” section in ch 6.
Let me know how you get on and if need be I’ll whip you up an example

Simon (Darkside) Jackson