if(Input.GetKeyDown(KeyCode.I))
{
//Open inventory
}
if(Input.GetKeyDown(KeyCode.Escape))
{
//Close the application
}
Programming commands
It is fairly common to have a key mapper. This allows players to customize the keys in use, and also works with a state machine to ensure only the valid keys are processed.
So you can detect if you are in the main game, and then map a variable key (which by default you mapped to "i") to an event that triggers the inventory UI. Elsewhere in your game, or in unity's built-in setup tool, allow the player to map the key to anything else, perhaps they like the "p" key or "\" key because it is similar to what they've got in another game.
Similarly, ESC could be mapped to many different events based on the state of the game. On some screens it could close the dialog, inside some transactions dialogs it could cancel the transaction, inside the main game it could pop up the menu, inside some menus it could back out one level or prompt to quit the game if at the root level.
Edit: Here's a link to Unity's Input Mapper class, if you need it. Again, note that instead of looking for a specific KeyCode value you would name a button, perhaps one called "Inventory" mapped to 'i' by default. You would test it with Input.GetButtonDown("Inventory").
It is fairly common to have a key mapper. This allows players to customize the keys in use, and also works with a state machine to ensure only the valid keys are processed.
So you can detect if you are in the main game, and then map a variable key (which by default you mapped to "i") to an event that triggers the inventory UI. Elsewhere in your game, or in unity's built-in setup tool, allow the player to map the key to anything else, perhaps they like the "p" key or "\" key because it is similar to what they've got in another game.
Similarly, ESC could be mapped to many different events based on the state of the game. On some screens it could close the dialog, inside some transactions dialogs it could cancel the transaction, inside the main game it could pop up the menu, inside some menus it could back out one level or prompt to quit the game if at the root level.
Edit: Here's a link to Unity's Input Mapper class, if you need it. Again, note that instead of looking for a specific KeyCode value you would name a button, perhaps one called "Inventory" mapped to 'i' by default. You would test it with Input.GetButtonDown("Inventory").
Ok, I got it, thanks for the tip .. I will find out more about key mapper! But on my other questions, I keep using the same algorithm I'm using?
If you're in the main menus, generate the menu events and broadcast them. If you're in the main game play, generate those events, if you're in the pause menu, generate those events. If you are in some other mode, maybe a dialog mode or interactive movie mode or qte event mode, generate and broadcast those appropriate events.