create a dynamic menu


I’m working on a point and click game where you can pick up and drop items from one box to the other. C#.

Each time a player is near a box (using OnCollision atm) I would like to list the contents of that box on the screen as buttons. Each button would have the name of the objects.

I’d like to, either in GUI or with 3d objects, create a menusystem that could show that.

-right now i have a switch checking to see which box the player is near, then it would load a given list of names (out of an arraylist) and show them on screen as text.


*I don’t know how to create buttons using each of these names. Could someone lead me in a good direction

*Are ArrayLists the best way to handle this kind of interaction?: eventually the “names” would become objects each with their own actions. Also objects should be able to be taken out/put into of a List when they are moved about the boxes.

An array is better, as you can edit it from the inspector. You need object, from a class you make yourself, not just names. In that class, you need the icon, why not a name, probably a prefab to instantiate. Then create an array of that type in your boxes, and display each objects.icon in the GUI.