Previous and Next buttons in Widget

Hey Everyone

Probably real simple, but at the moment, it’s just not coming to me.

I have an Int array that has 10 indexes. In a widget, I have ‘+’ and ‘-’ buttons which I want to use to cycle through each index in the array starting at 0.

I’m having some trouble figuring it out and am hoping someone here is able to help me.


There’s more than one way to do it, I usually settle for this:

This will work with any array size. You may want to catch an exception for an empty array, though - as it makes no sense to run the script when no elements are present, and it will incorrectly return index 0.

Thanks for this. It’s basically for an Inventory where a widget pops up where the player can drop a certain amount of an item. The array will never be empty in my case as it won’t even get this far unless there are more than 1 items to drop.

I’ll give this one a shot. Thanks heaps.