|
Post by nitrox32 on Sept 23, 2019 23:59:27 GMT
Currently I'm developing a pause menu screen in my game that I would like to use the Escape key to open. I use a simple script that uses Input.GetKeyDown(KeyCode.Escape) to check to see if the escape key has been pressed and it works fine. The problem is that when the inventory window is open, the inventory system uses the escape key to navigate back from some of the screens. When I press the escape key to return from these screens my pause screen opens and closes. How can I remap the inventory back button to something else so that I doesn't conflict?
Perhaps another approach would be to have my pause menu script not check for the Escape key if the inventory window is open. Any suggestions on how I might approach this? I not much of programmer but this seems fairly simple to do.
|
|
|
Post by nitrox32 on Sept 24, 2019 1:37:18 GMT
So I think what I ultimately would like to do is use the escape key as the back button when the inventory is being used and to open the pause window when the inventory is not being used. I modified my script to check if any inventory windows are open, if they are, then don't monitor the escape key to open the pause window. This is working fine keeping the pause window from opening when using the escape key during inventory operations. The problem comes after closing the inventory. When I open the pause menu and click on any of the menu buttons, the mouse cursor goes away and the buttons don't respond. I think this has something to do with the way Invector uses the escape key during inventory operations. Does anyone have any thoughts?
|
|
|
Post by Invector on Sept 24, 2019 13:57:01 GMT
We use the event OnOpenCloseInventory to enable/disable the cursor and lock/unlock to center, you can call the same methods on your menu
|
|
|
Post by nitrox32 on Sept 28, 2019 22:53:40 GMT
OK that makes sense. I have these currently in my Item Manager Open/Close inventory events. How would I add these to my pause menu? I have a script that opens the pause menu when the escape key is pressed. I'm not much of a programmer so can I add these to my pause menu game object in a similar way to the Item Manager? Better yet, does Invector have some sort of way generic controller that would allow me to open the pause menu and add those events like the Item Manager Open/Close inventory events?
|
|
|
Post by Invector on Sept 30, 2019 14:32:57 GMT
You could remove this calls from the ItemManager and have it managed by the GameController of your game, when 'x' button is pressed, the cursor shows up/hide
|
|
|
Post by nitrox32 on Sept 30, 2019 21:22:14 GMT
I was able to toggle the cursor lockstate through script. When running the game scene everything works fine. The in game pause menu/options window as well as the inventory windows work as expected. The problem now is when I leave to different scene from the pause menu to the main menu scene. When I come back, the cursor will no longer becomes visible when using the inventory system. The cursor still functions properly with the in game menu screen. This behavior only happens when leaving the game scene into to main menu screen then back. If I start with the main menu then go into the game scene everything works fine until I exit the game scene then come back. So my question is why would toggling the lockstate for the inventory window not work when leaving then returning to a scene? It works for my pause menu which calls the same function to toggle the lockstate.
|
|