Forum rules - please read before posting.

Inventory Item Strange Behaviour

edited March 2021 in Technical Q&A

Hi,
I'm currently stuck with a strange error, and no matter how long I've tried to debug, I didn't find why this is happening: I've got a menu made with its source set as Unity UI Prefab and the appear type set as "During Gameplay". I've also added a SceneController script to the gameEngine object, which is extremely simple:

`private void OnEnable()
{
    EventManager.OnInventoryDeselect += UnlockInGameMenu;
    EventManager.OnInventorySelect += LockInGameMenu;
}

private void OnDisable()
{
    EventManager.OnInventoryDeselect -= UnlockInGameMenu;
    EventManager.OnInventorySelect += LockInGameMenu;
}

private void UnlockInGameMenu(InvItem invItem)
{
    Debug.LogWarning("Inventory Item Deselected");
    PlayerMenus.GetMenuWithName("InGame").isLocked = false;
    PlayerMenus.GetMenuWithName("InGame").TurnOn();
}

public void LockInGameMenu(InvItem invItem)
{
    Debug.LogWarning("Inventory Item Selected");
    PlayerMenus.GetMenuWithName("InGame").isLocked = true;
    PlayerMenus.GetMenuWithName("InGame").TurnOff();
}`

Now, what I'm experiencing is this (with pictures shown here: If I select an Item which is present in my inventory, via an interaction that simply selects the item in USE mode and closes the inventory (see first image of link), then everything is fine, the InGame Menu disappears and doesn't reappear unless I deselect the item or use it successfully on the intended hotspot.

If, on the other hand, I interact with an hotspot that works slightly like the arrangingPuzzle example, i.e. an hotspot that gives me an item which doesn't exist in the inventory (see second and third image), the InGame Menu doesn't disappear, although the script gets called anyway.

Any idea of what could be the cause?
Willy

Comments

  • edited March 2021

    What's your AC version?

    This may be a bug with Unity UI-based Menus. Does reverting your InGame menu's Source to Adventure Creator cause it to behave correctly?

  • Sorry Chris,
    I forgot to mention. I'm using Unity 2020.2.0f and AC version 1.72.4.

    Reverting the InGame menu's Source to Adventure Creator does, in fact, cause it to behave correctly.

  • No problem.

    I'll look into this, and let you know if I need any additional info. Thanks for the bug report.

  • Recreated, I shall work on a fix for the next update.

    In the meantime, try calling Menu.TurnOff before setting IsLocked to true.

  • In the meantime, try calling Menu.TurnOff before setting IsLocked to true.

    Thanks Chris,
    that did the trick!

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.