Forum rules - please read before posting.

Disabling "Pauses game?" in the Inventory makes the inventory unusable

Hey Chris,

My game uses direct control for everything, so there's no mouse input (you already know this). I'm using Unity UI for the inventory, and it works fine when "Pauses game?" is enabled. However, I can't use inventory items in the game since the game is paused when the inventory is open.

When I disable "Pauses game?", the inventory starts behaving weirdly:

https://prnt.sc/B9iqSYTCQ9Vr
https://prnt.sc/ob97M0XYhZs_
https://prnt.sc/RXzulV2h3c0s

Any idea how to fix this? Preferably keeping "Pauses game?" enabled.

«1

Comments

  • Another inventory issue I forgot to mention: numbers appear next to each inventory item. I've checked everything, but I still can't remove them. https://prnt.sc/xJvxKmkiwOlc

  • If your directly-controlled Menu runs during gameplay, you'll need to specifically allow for direct navigation using the Engine: Manage systems Action.

    See the Manual's "Navigating menus directly" chapter for details.

    Another inventory issue I forgot to mention: numbers appear next to each inventory item. I've checked everything, but I still can't remove them.

    Is the InventoryBox element's Index prefix display field set to None?

  • I did use Engine: Manage systems to allow for direct navigation, however I still can't use Inventory items in the game. Can you elaborate more on this please?

  • Just to clarify, I'm trying to use my inventory menu while the "Pauses game" option is checked. Everything seems to be working fine, except when trying to use an inventory item on a hotspot—nothing happens.

  • edited March 7

    Can you share details of how Hotspots are being interacted with, starting with your Settings Manager?

  • My settings manager: https://prnt.sc/QFWigmBKsnXn
    My interaction with hotspots is simple:

    • I create a Hotspot 2D with an interaction.
    • The player can use an inventory item when within the hotspot's boundary.

    It works fine when I uncheck "Pauses game" in the inventory menu. However, once "Pauses game" is checked, nothing happens when I try to use an inventory item.
    https://prnt.sc/PsfevYwjb5qr
    https://prnt.sc/G_vAO2xpXhS2

  • Sorry, I mean to see your full Settings Manager. Are you using any custom scripts, also?

  • Yes, I'm using a custom script:

    using UnityEngine;
    using UnityEngine.EventSystems;
    using UnityEngine.UI;

    [RequireComponent(typeof(Button))]
    [RequireComponent(typeof(Image))]
    [RequireComponent(typeof(RectTransform))]
    public class HandleInventoryInteraction : MonoBehaviour, ISelectHandler, IDeselectHandler
    {
    public RectTransform _centerRectTransform; // Assign in Inspector
    public RectTransform _parentTransform; // Assign in Inspector

    private Button _button;
    private Image _image;
    private RectTransform _rectTransform;
    
    private void Awake()
    {
        // Get required components
        _button = GetComponent<Button>();
        _image = GetComponent<Image>();
        _rectTransform = GetComponent<RectTransform>();
    
        // Check for missing components or references
        if (_rectTransform == null)
        {
            Debug.LogError($"[{gameObject.name}] Missing RectTransform component.", this);
        }
    
        if (_parentTransform == null)
        {
            Debug.LogWarning($"[{gameObject.name}] _parentTransform is not assigned in the Inspector.", this);
        }
    
        if (_centerRectTransform == null)
        {
            Debug.LogWarning($"[{gameObject.name}] _centerRectTransform is not assigned in the Inspector.", this);
        }
    
        // Apply initial deselected state
        onDeselected();
    }
    
    void onDeselected()
    {
        if (_image == null || _rectTransform == null)
        {
            Debug.LogWarning($"[{gameObject.name}] Missing references in onDeselected. _image or _rectTransform is null.", this);
            return;
        }
    
        // Change color and scale for deselected state
        _image.color = new Vector4(1f, 1f, 1f, 0.4f); // Semi-transparent
        _rectTransform.localScale = new Vector3(0.8f, 0.8f, 0.8f); // Scaled down
    }
    
    void onSelected()
    {
        // Debug missing references
        if (_parentTransform == null || _centerRectTransform == null || _rectTransform == null)
        {
            Debug.LogWarning($"[{gameObject.name}] Missing references in onSelected. " +
                             $"_parentTransform: {(_parentTransform == null ? "null" : _parentTransform.name)}, " +
                             $"_centerRectTransform: {(_centerRectTransform == null ? "null" : _centerRectTransform.name)}, " +
                             $"_rectTransform: {(_rectTransform == null ? "null" : _rectTransform.name)}", this);
            return;
        }
    
        // Adjust parent position to align with the center
        _parentTransform.transform.localPosition = new Vector3(
            _centerRectTransform.transform.localPosition.x - _rectTransform.transform.localPosition.x,
            _centerRectTransform.transform.localPosition.y,
            _centerRectTransform.transform.localPosition.z
        );
    
        // Change color and scale for selected state
        _image.color = Vector4.one; // Fully visible
        _rectTransform.localScale = Vector3.one; // Default scale
    }
    
    #region Implement Interface
    
    public void OnSelect(BaseEventData eventData)
    {
        Debug.Log($"[{gameObject.name}] Selected.");
        onSelected();
    }
    
    public void OnDeselect(BaseEventData eventData)
    {
        Debug.Log($"[{gameObject.name}] Deselected.");
        onDeselected();
    }
    
    #endregion
    

    }

  • And your Settings Manager?

  • You can't select a Hotspot outside of gameplay to interact with it - you'll need to come out of pause mode.

    Is the pause mode requirement due to e.g. animation / sound in the scene? They could potentially be paused through scripting.

  • I don't mind unchecking "Pauses game", but when I exit pause mode, my inventory encounters these two issues:

    Any idea how to fix these?

    P.S. same things happens when I switch to AC inventory

  • These videos don't provide the context needed. How can I recreate these issues from a standard new game created with the New Game Wizard?

  • edited March 14

    I don't think this issue will happen if you start a New Game Wizard. Is there a debug function or code I can implement to help us learn more about the issue?

    Currently, the main issue is that when I press "E" on an inventory item, it gets deselected and grayed out, forcing me to close the inventory and reopen it to select the item again.

  • You can use the Events Editor to create an "Inventory / Deselect" event that runs an ActionList: Comment Action to put some Debug text in the Console - you can follow its stacktrace to learn why the item is becoming deselected at that time.

  • edited March 16

    I’ve decided to revert back to using AC Inventory as the source for the inventory. However, it seems that AC Inventory is experiencing the same issues when "Pauses game" is unchecked. The AC inventory used to work fine before I implemented my custom inventory.

    Is there a way to reset the inventory or something similar to resolve this?

  • You can get the default Inventory menu by temporarily switching your Menu Manager asset file (at the top of the window) to Default_MenuManager.

    From there, you can then Copy the default Inventory menu, revert back to your own Menu Manager, and Paste it in.

  • Strangely, my AC game editor has been using the default manager for all my scenes (Scene, Menu, Actions, etc.). This means that all along, I’ve been working with the default manager.

    Is it okay to continue using it?

    Aside from that, whether I use the default manager or my custom game manager, the AC inventory won’t work or navigate when “Pauses game?” is unchecked.

  • You'll want to use your own set of Managers - created using the New Game Wizard - otherwise you'll run the risk of overwriting your game's data when upgrading AC.

    The other way around this would be to ensure you omit the Default Managers from the Import dialog box when importing AC from the Package Manager.

    Aside from that, whether I use the default manager or my custom game manager, the AC inventory won’t work or navigate when “Pauses game?” is unchecked.

    I'll need more details on the exact behaviour? Are you trying to directly-navigate the Menu, or is the cursor intentionally active at the time?

  • Here's the exact behaviour:

    I'm happy to share the source code with you if you're interested in investigating it.

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.