• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Best way to do a pop-up UI?

H

Hugtality

Guest
I'm about to start work on a pop-up UI that the player can bring up mid-game with a button press to change their weapons. When called upon, the inventory needs to appear on top of the game, needs to be interactive, and its contents need to change depending on which weapons the player has acquired.

Would the most efficient way to do this be through creating objects or drawing GUI?

My primary thought was to have an inventory object that's just the background, as well as individual objects for every item appearing in the inventory that can get changed out as needed. Then, when called upon, the inventory creates the background object, then creates an object for every item that appears in it and aligns them accordingly.

I'm guessing a method using Draw GUI is also possible, but I'm not super confident with the Draw GUI event as a whole and would only like to use it if its absolutely the best option.
 

OnLashoc

Member
I am currently doing something pretty similar and it's pretty simple as far as what you are wanting to do, but I personally wouldn't put it on the GUI layer but to each their own. I have control objects with no images that contain my code to create or destroy objects on a specific buttons press. For instance, I have a market and on upon pressing the space button, the market window pop's up. The market object is set to the top most layer so it draws over everything else.

And if you are in a fight and your weapons are out or shooting, the market will not pop up and vice versa. If the market window is open, then weapons will not shoot. In the market you can buy trade items, weapon and part upgrades etc, but if you're on a planet without a colony no market information will populate. This market window also include a display of what and how many of said items are in your inventory as well as your credit balance.
 
The way I do my menus is just through one object drawing and handling everything. It's simple to work on because everything is contained within one script. I also don't see the issue with using the GUI layer. It's just a separate layer.
 

OnLashoc

Member
Yea there really isnt anything saying you shouldn't, but there's nothing saying you have to. It's a matter of preference.
 
The way I'm doing my battle menus, I have sprites for individual player abilities rather than individual objects. I set up the menu object with an extremely small x and y scale which increases until it hits full size. Only then are things like the abilities, text, or player cursor drawn. That way it looks like the menu is expanding rather than simply popping into existence. Other than the fact that I'm drawing everything within one object rather than creating several, its essentially the same as your idea. As everyone else has already suggested, it doesn't need to be on the GUI layer as long as its on a layer that's drawn on top of everything else.
 
Top