Forum rules - please read before posting.

Disabling a specific input on a Specific Menu

2»

Comments

  • I think it may be a red herring. Check for custom scripts that may be reading input - if it's not coming from the Input Manager, try searching for instances of "Input.GetMouseButtonDown" in any custom scripts you have.

  • Hello Chris, appreciate your help so far.

    Went through all Scripts I could find one-by-one searching for that keyword and could only found something similar on a Script for the FlashHold (which we use for Revealing Hotspots using "mouse 2".

    I am copying the content of that script next:

            using UnityEngine;
            using AC;
    
            public class FlashHold : MonoBehaviour
            {
                public string inputName = "FlashHold";
                public bool isInGameplay;
    
                private void OnEnable()
                {
                    EventManager.OnExitGameState += OnExitGameState;
                }
    
                private void OnDisable()
                {
                    EventManager.OnExitGameState -= OnExitGameState;
                }
    
                private void Update()
                {
                    if (isInGameplay)
                    {
                        if (Input.GetButtonDown(inputName))
                        {
                            FlashHotspots();
                        }
                        else if (Input.GetButtonUp(inputName))
                        {
                            FlashHotspots(true);
                        }
                    }
                }
                private void OnExitGameState(GameState gameState)
                {
                    isInGameplay = (gameState != GameState.Normal);
                    if (!isInGameplay)
                    {
                        FlashHotspots(true);
                    }
                }
    
                private void FlashHotspots(bool cancel = false)
                {
                    foreach (Hotspot hotspot in KickStarter.stateHandler.Hotspots)
                    {
                        if (hotspot.highlight)
                        {
                            if (cancel)
                            {
                                hotspot.highlight.CancelFlash();
                            }
                            else if (hotspot.IsOn() && hotspot.PlayerIsWithinBoundary() && hotspot != KickStarter.playerInteraction.GetActiveHotspot())
                            {
                                hotspot.highlight.flashHoldTime = 1000f;
                                hotspot.highlight.Flash();
                            }
                        }
                    }
                }
            }
    

    Also here´s the Script that controls the Notebook Menu from the GIF if you wanna check it out:

    using UnityEngine;
    using AC;
    
    public class NotebookController : MonoBehaviour
    {
        private MenuInventoryBox inventoryBox;
        private int slotIndex;
    
        public void Update()
        {
    
        }
    
        private void OnEnable() { EventManager.OnMouseOverMenu += OnMouseOverMenu; }
        private void OnDisable() { EventManager.OnMouseOverMenu -= OnMouseOverMenu; }
        public void OnMouseOverMenu(Menu menu, MenuElement element, int slot)
        {
            if (menu.title == "Notebook " && element != null && element.title == "Inventory Box Clues")
            {
                //InvInstance item = inventoryBox.GetInstance(slot);
                //Debug.Log((item));
                //if (InvInstance.IsValid(item))
                //{
    
                //}
                //MenuInventoryBox inventoryBox = element as MenuInventoryBox;
                //InvItem item = inventoryBox.GetItem(slot);
    
            }
            //Debug.Log((slot));
        }
    
        public void IsUsed()
        {
            InvInstance slotInstance = inventoryBox.GetInstance(slotIndex);
            KickStarter.runtimeInventory.PlayerInvCollection.GetFirstInstance(slotIndex).GetProperty("Clues Flagged").BooleanValue = true;
        }
    
        public void Scratch003()
        {
            InvInstance myItem = KickStarter.runtimeInventory.GetInstance(3);  // The item with ID = 3
            myItem.GetProperty("Clues Flagged").BooleanValue = true;
        }
    }
    
  • Nothing related, so far as I can see.

    At this point, I think the only way we're going to get to the bottom of this is for you to zip up the project and PM me a link, along with instructions on how to recreate the issue in the simplest way (e.g. start from this scene and click here).

  • Just sent you a PM!

  • edited April 21

    Thanks.

    So this occurs because the "clue" buttons each rely on an Event Trigger component to detect mouse clicks - but it doesn't allow for distinguishing between left and right mouse buttons.

    To get around this, you can use a custom Event System module that ignores right-clicks entirely.

    To do this, locate your custom EventSystem prefab, and replace its Standalone Input Module component with the following:

    using UnityEngine.EventSystems;
    using AC;
    
    public class LeftClickOnlyModule : OptionalMouseInputModule
    {
        protected override MouseState GetMousePointerEventData (int id = 0)
        {
            if (KickStarter.settingsManager == null || KickStarter.settingsManager.inputMethod == InputMethod.MouseAndKeyboard)
            {
                var m_MouseState = base.GetMousePointerEventData (id);
                PointerEventData _rightData;
                GetPointerData (kMouseRightId, out _rightData, true);
                _rightData.button = PointerEventData.InputButton.Right;
                m_MouseState.SetButtonState (PointerEventData.InputButton.Right, PointerEventData.FramePressState.NotChanged, _rightData);
                return m_MouseState;
            }
            return base.GetMousePointerEventData (id);
        }
    }
    
  • edited April 21

    Thanks for the quick response and checking out the project.

    Will try soon

  • edited April 22

    It seemed to work! Thanks so much, I am so glad you worked it out for me ;) :)
    It was gonna be impossible for me to figure it out on myself.

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.