Forum rules - please read before posting.

Losing focus during gameplay deselects inventory items

Hi Chris,

We’ve run into an issue where selected inventory items get automatically deselected when the game loses focus specifically while player control is blocked (e.g. during a dialogue).

Steps to reproduce:

  1. Start a dialogue (or any situation where “Control is blocked”).
  2. Alt+Tab or switch focus to another window while the dialogue is still active.
  3. Return to the game after a few seconds.
  4. Select an item from the inventory.

Result:

  • The mouse cursor may disappear.
  • The selected inventory item is automatically deselected.
  • After the dialogue ends, the item can no longer be used — it gets dropped instantly when clicked.

Workaround:

Restarting the game or switching to a different scene restores normal item selection behavior.

Here’s a video showing the behavior

Unity version: 6000.0.49f1
Adventure Creator version: 1.83.0

Thanks again for your support!

Comments

  • What platform are you working on? To be clear: this is about selecting new items after switching focus, rather than items becoming deselected at the time you switch?

    What are you using for input, and what is your project's "Active Input Handling" set to?

    If you create an Inventory / Deselect event in the Events Editor, and have it run an ActionList: Comment Action, you can print some debug text in the Console when items become deselected. What does it say - in full - when the issue occurs?

  • Thanks for your quick reply!

    • Platform: We’re working on Windows and Mac, but in Editor as well.
    • Yes, the issue happens when trying to select a new item after returning focus to the game. The item appears to be selected briefly, then gets immediately deselected. It does not happen at the moment focus is lost — only when trying to interact afterward.
    • Input: We’re using standard mouse input, no custom input system.
    • Active Input Handling: Currently set to Both (in Unity Project Settings > Player > Other Settings > Active Input Handling).

    I’ve now created an Inventory / Deselect event in the Events Editor, with an ActionList: Comment that logs a debug message.

    When the issue happens, I see the comment appear immediately after trying to select an inventory item once the focus has returned.

    So something is clearly triggering a deselect right after selection in that context.

    Let me know if there’s anything else I can try or check!

  • I’ve found consistent repro steps that always trigger the issue:

    1. Select an inventory item so that it appears on the cursor (i.e. ready to be used).
    2. Pause the game (using AC.KickStarter.stateHandler.gameIsPaused = true; or any equivalent Pause Game action).
    3. Resume the game.
    4. After resuming, inventory interaction becomes broken:
    • The selected item is no longer usable.
    • Clicking an item briefly shows it as selected, but it’s immediately deselected.

    Here’s a video showing the issue

    Let me know if you need more info!

  • I cannot reproduce such behaviour.

    Are you using Input System to read mouse input, along with AC's integration for it?

    When the issue happens, I see the comment appear immediately after trying to select an inventory item once the focus has returned.

    What is the message in full, stacktrace included?

  • Here is full stacktrace

    Inventroy Deselect
    (From Action #0 in ActionList 'OnInventoryDeselect')
    
     -> AC debug logger
    UnityEngine.Debug:LogWarning (object,UnityEngine.Object)
    AC.ACDebug:LogWarning (object,AC.ActionList,AC.Action,UnityEngine.Object) (at Assets/AdventureCreator/Scripts/Static/ACDebug.cs:89)
    AC.Action:LogWarning (string,UnityEngine.Object) (at Assets/AdventureCreator/Scripts/ActionList/Action.cs:1805)
    AC.ActionComment:Run () (at Assets/AdventureCreator/Scripts/Actions/ActionComment.cs:58)
    AC.ActionList/<RunAction>d__47:MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:471)
    UnityEngine.MonoBehaviour:StartCoroutine (System.Collections.IEnumerator)
    AC.ActionList:ProcessAction (int) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:413)
    AC.RuntimeActionList:BeginActionList (int,bool) (at Assets/AdventureCreator/Scripts/ActionList/RuntimeActionList.cs:181)
    AC.ActionList:Interact (int,bool) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:283)
    AC.RuntimeActionList:DownloadActions (AC.ActionListAsset,AC.Conversation,int,bool,bool,bool) (at Assets/AdventureCreator/Scripts/ActionList/RuntimeActionList.cs:136)
    AC.AdvGame:RunActionListAsset (AC.ActionListAsset,AC.Conversation,int,bool,bool) (at Assets/AdventureCreator/Scripts/Static/AdvGame.cs:257)
    AC.AdvGame:RunActionListAsset (AC.ActionListAsset,int,int) (at Assets/AdventureCreator/Scripts/Static/AdvGame.cs:178)
    AC.ActionListAsset:Interact () (at Assets/AdventureCreator/Scripts/ActionList/ActionListAsset.cs:559)
    AC.EventBase:Run (object[]) (at Assets/AdventureCreator/Scripts/Events/EventBase.cs:136)
    AC.EventInventorySelect:OnInventoryDeselect (AC.InvCollection,AC.InvInstance) (at Assets/AdventureCreator/Scripts/Events/Events/EventInventorySelect.cs:81)
    AC.EventManager:Call_OnChangeInventory (AC.InvCollection,AC.InvInstance,AC.InventoryEventType,int) (at Assets/AdventureCreator/Scripts/Managers/EventManager.cs:1750)
    AC.RuntimeInventory:SetNull () (at Assets/AdventureCreator/Scripts/Inventory/RuntimeInventory.cs:114)
    AC.ActionInventorySelect:Run () (at Assets/AdventureCreator/Scripts/Actions/ActionInventorySelect.cs:88)
    AC.ActionList/<RunAction>d__47:MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:471)
    UnityEngine.MonoBehaviour:StartCoroutine (System.Collections.IEnumerator)
    AC.ActionList:ProcessAction (int) (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:413)
    AC.ActionList/<DelayProcessAction>d__45:MoveNext () (at Assets/AdventureCreator/Scripts/ActionList/ActionList.cs:395)
    UnityEngine.SetupCoroutine:InvokeMoveNext (System.Collections.IEnumerator,intptr) (at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/Coroutines.cs:17)
    

    Are you using Input System to read mouse input, along with AC's integration for it?

    Hard to tell, I think everything is default.

  • The item in this case - given the stacktrace - is becoming deselected because of an Inventory: Select Action with a Select type of Deselect Active being run.

    You can use the Actions Manager to print a list of instances of this Action in the Console.

  • Hey Chris,

    Huge thanks – you basically saved our lives with this one! 🙌 Your hint led us straight to the issue.

    It turned out that the problem was caused by an Inventory: Select action with the Deselect. This was part of an ActionList that was triggered when the pause menu opened. However, we expected it to run only when the menu is turned on via the Menu Manager (ActionList when turn on: for the Pause menu).

    But here’s the confusing part: it kept firing even after we had already closed the menu. Do you know why this might be happening? Does the ActionList somehow keep running after the menu has been turned off?

    Here is a screenshot of the ActionList for context.

    image

    Thanks again – really appreciate your help!

  • What are the ActionList's properties, and how is it set to run? In the Menu's ActionList when turn on field?

  • Yes, exactly — the ActionList is assigned in the menu’s “ActionList when turn on” field for the Pause menu.

    properties

  • And when/how is the Pause menu turned on?

  • The Pause menu is turned on by a button in the Inventory, using the Crossfade menu command in Menu Manager.

  • Try the same method as in the other thread, i.e. swapping out the Managers (fully and then partially) for that of the Demo game.

    In Demo_MenuManager, you can alter the Inventory menu's ShiftLeft button to crossfade to the Pause menu to have it behave similar to your own game.

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.