Forum rules - please read before posting.

Block inventory

Hi. How i can block any inventory interactions while paused menu is on?

Comments

  • Welcome to the community, @badCube.

    The default interface causes the game to pause when the Pause menu turns on - this will disable the InGame and Inventory menus at the same time.

    It looks like you've unchecked the Pause menu's Pause game when enabled? - is it your intent to have the game not be paused, but still have the Inventory menu be locked?

    A Menu can be locked off with the Menu: Change state Action. If a Menu is locked, it will not display even if it's Appear type condition is met.

    To have the Inventory menu lock itself when the Pause menu turns on, you could run this Action inside the Pause menu's ActionList when turn on asset, and similarly unlock it when the Pause menu turns off.

  • Thx for quick answer. I have checked Pause game when enabled? on screenshot above. I want to Invenory menu still be visible but not interactable while pause menu is on.

  • So effectively, you'd be looking to check the Inventory menu's Ignore input? property when the Pause menu turns on?

    You can achieve this through scripting: the OnMenuTurnOn and OnMenuTurnOff custom events will fire when the Pause menu turns on and off, and you can use this to alter the property at this time.

    To alter any Manager field through script, just right-click the field's label to get an API reference you can copy/paste into code.

    Here's a sample script, DisableInventory.cs, that should handle this if you attach it to a GameObject in the scene:

    using UnityEngine;
    using AC;
    
    public class DisableInventory : MonoBehaviour
    {
    
        private void OnEnable ()
        {
            EventManager.OnMenuTurnOn += OnMenuTurnOn;
            EventManager.OnMenuTurnOff += OnMenuTurnOff;
        }
    
        private void OnDisable ()
        {
            EventManager.OnMenuTurnOn -= OnMenuTurnOn;
            EventManager.OnMenuTurnOff -= OnMenuTurnOff;
        }
    
        private void OnMenuTurnOn (AC.Menu menu, bool isInstant)
        {
            if (menu.title == "Pause")
            {
                PlayerMenus.GetMenuWithName ("Inventory").ignoreMouseClicks = true;
            }
        }
    
        private void OnMenuTurnOff (AC.Menu menu, bool isInstant)
        {
            if (menu.title == "Pause")
            {
                PlayerMenus.GetMenuWithName ("Inventory").ignoreMouseClicks = false;
            }
        }
    
    }
    
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.