Forum rules - please read before posting.

OnInventoryDeselect not working

For some reason, I cannot get the OnInventoryDeselect event to run, even though OnInventorySelect works fine and just as expected. Here is the code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using AC;

public class enableDisableItemBlockers : MonoBehaviour

private void OnEnable()
    EventManager.OnInventorySelect += OnInventorySelect;
    EventManager.OnInventoryDeselect += OnInventoryDeselect;

private void OnDisable()
    EventManager.OnInventorySelect -= OnInventorySelect;
    EventManager.OnInventoryDeselect -= OnInventoryDeselect;

private void OnInventorySelect(InvItem invItem)

private void OnInventoryDeselect(InvItem invItem)


I attached the script to the inventory box (it's always enabled) if that matters. I've tried all forms of deselecting - right click, left click, placing it back onto itself, deselecting through an actionlist - and nothing works. The goal is to have this trigger when any of the items is selected or deselected, not any one item in particular.

What am I doing wrong? TIA!


  • The code looks fine - and it works on my end, provided the Inventory menu it's attached to is always enabled, as you've described.

    What's your AC version, and what's the result of attaching it to an empty GameObject in the scene?

  • Tried attaching to an empty within the unity UI menu and within a game scene, but the results are the same - select shows up in the log but deselect doesn't.

    AC version is 1.70.1, which is pretty old, but we're also working with unity version 2018.3.0f2 because we started this project forever ago. Any chance this is the problem?

  • It's a very old version, to be sure.

    The only related issue that release ought to have, though, is that the event won't be called if the Item itself is not in the Player's Inventory.

    If you open up AC's RuntimeInventory script, look for the SetNull function around line 131. This is where the event gets called.

    You can try placing a Debug.Log statement in there to check if it's being called, but removing the && _localItems.Contains (selectedItem) block may be what's needed.

  • Removing && _localItems.Contains (selectedItem) did it! Thank you so much for your patience!

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.