Forum rules - please read before posting.

OnInventorySelect Event Not Triggering in Adventure Creator

2»

Comments

  • Thank you for your detailed response and for providing a solution to the issue I was experiencing with the Interaction menu.
    After implementing the changes you proposed in the MenuInteraction script, the Inventory menu and Interactions element started reacting to the OnMouseMenuOver event when using the mouse. Unfortunately, they don't respond to keyboard movements, but for my specific needs, this is fine. I can handle the automatic smooth input switching, so I'm happy that I can now continue with my project. I really appreciate your help with this!

    Following your suggestion, I connected the ConversationUI menu from the original Adventure Creator prefab and recorded a video where I show the entire configuration and run the project in 4 different configurations: for InputMethod.MouseAndKeyboard and InputMethod.KeyboardOrController, and with keyboardControl set to true/false.

    It appears that the OnMouseMenuOver event in the ConversationUI is triggered for the keyboard only in the configuration: InputMethod.KeyboardOrController and keyboardControl = false.

    You can watch the video here: https://www.youtube.com/watch?v=y9aSxsCc8mo
    I hope it shows all the relevant elements and will be helpful in troubleshooting this issue further.

    This is my recent version of OnMouseOverMenu:

    public void OnMouseOverMenu (AC.Menu menu, MenuElement element, int slot) 
            {
                print("ENTER OnMouseOverMenu | " +
                    " gameState: " + KickStarter.stateHandler.gameState + 
                    " canKeyboardControlMenusDuringGameplay: " + KickStarter.playerInput.canKeyboardControlMenusDuringGameplay +
                    " keyboardControlWhenPaused" + KickStarter.menuManager.keyboardControlWhenPaused +
                    " keyboardControlWhenDialogOptions: " + KickStarter.menuManager.keyboardControlWhenDialogOptions
                );
    
                if (menu == null)
                    print("OnMouseOverMenu | Menu is null!");
    
                if (element == null)
                    print("OnMouseOverMenu | Menu element is null, menu:" + menu.title);
    
                if (menu == null || element == null)
                    return;
    
                print("OnMouseOverMenu: " + menu.title + " | element: " + element.title + " | slot: " + slot);
    
                lastSelectedMenuElement = element;
                lastSelectedSlot = slot;
    
                if (menu.title == "Interaction" && element.title == "Interactions")
                {
                    if (!AC.KickStarter.playerInput.canKeyboardControlMenusDuringGameplay)
                    {   
                        interactionMenu.Select ("Interactions", lastSelectedSlot);
                    }               
                }
    
                if (menu.title == "Interaction" && element.title == "InventoryBox")
                {
                    if (!AC.KickStarter.playerInput.canKeyboardControlMenusDuringGameplay)
                    {   
                        interactionMenu.Select ("InventoryBox", lastSelectedSlot);
                    }               
                }
    
                if (menu.title == "Conversation" && element.title == "DialogueList" && !conversationEnded)
                {
                    if (!AC.KickStarter.menuManager.keyboardControlWhenDialogOptions)
                    {   // if mouse used
                        conversationMenu.Select ("DialogueList", lastSelectedSlot);
                    }
                }
    
                if (menu.title == inventoryMenuName && element.title == "InventoryBox")
                {
                    if (!AC.KickStarter.playerInput.canKeyboardControlMenusDuringGameplay)
                    {
                        inventoryMenu.Select ("InventoryBox", lastSelectedSlot);
                    }
                }
    
                if (menu.title == inventoryInteractionMenuName && element.title == "Interactions")
                {
                    if (!AC.KickStarter.playerInput.canKeyboardControlMenusDuringGameplay)
                    {
                        inventoryInteractionMenu.Select ("Interactions", lastSelectedSlot);
                    }               
                }
    
                if (menu.title == "Pause")
                {
                    if (!AC.KickStarter.menuManager.keyboardControlWhenPaused)
                    {   // if mouse over is made by mouse
                        pauseMenu.Select(lastSelectedMenuElement, 0);
                    }
                }
            }
    

    Ane most recent version of Input detection:

    private void AutoSwitchInputMethod()
            {
                if (anyGamepadKeyPressedDetected)
                {
                    SwitchInputMethod(InputMethod.KeyboardOrController, true);
                }
                else if (Keyboard.current.anyKey.IsPressed())
                {
                    SwitchInputMethod(InputMethod.MouseAndKeyboard, true);
                }
                else if (isMouseMoveDetected || Mouse.current.leftButton.isPressed || Mouse.current.rightButton.isPressed)
                {               
                    SwitchInputMethod(InputMethod.MouseAndKeyboard, false);
                }
            }
    
            private void SwitchInputMethod(InputMethod newInputMethod, bool keyboardControl, bool forceInputChange = false)
            {
                if (AC.KickStarter.settingsManager.inputMethod != newInputMethod || forceInputChange)
                {
                    AC.KickStarter.settingsManager.inputMethod = newInputMethod;
                }
    
                if (AC.KickStarter.menuManager.keyboardControlWhenPaused != keyboardControl ||
                    AC.KickStarter.menuManager.keyboardControlWhenDialogOptions != keyboardControl ||
                    AC.KickStarter.menuManager.keyboardControlWhenCutscene != keyboardControl ||
                    AC.KickStarter.playerInput.canKeyboardControlMenusDuringGameplay != keyboardControl)
                {
                    AC.KickStarter.menuManager.keyboardControlWhenPaused = keyboardControl;
                    AC.KickStarter.menuManager.keyboardControlWhenDialogOptions = keyboardControl;
                    AC.KickStarter.menuManager.keyboardControlWhenCutscene = keyboardControl;
                    AC.KickStarter.playerInput.canKeyboardControlMenusDuringGameplay = keyboardControl;
                }
            }
    

    If it would be helpful, I can export a Unity package with my current configuration and scripts and share it with you. Let me know if that would be useful.

    I look forward to any further advice or suggestions you might have.

  • If it would be helpful, I can export a Unity package with my current configuration and scripts and share it with you. Let me know if that would be useful.

    I agree that it would be best for me to see things for myself. However, given the use of other packages and scripts, it's likely a case of having the entire project - or at least a cut-down one that demonstrates the issue.

    If you can provide a zip link to such a project, along with instructions on how to recreate the issue, PM it to me and I shall investigate.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.