Forum rules - please read before posting.

Select inventory items with simulated cursor using Unity UI?


In AC 1.68 Unity UI-based menus now respond to simulated cursors when the "Input method" is set to "Keyboard Or Controller". However, the simulated cursors don't seem to respond to inventory items. Items can't be selected and aren't highlighted when hovering over. I know inventory items can be directly selected using the "First selected Element" in the menu option as well as through actions, but is there a way simulated cursors can respond to inventory items? It just feels odd if I can control the cursor with my controller when the inventory is open, but not being able to interact with the items.



  • There is still an issue with the "hover" graphic showing correctly, but the item itself should still be interactive. I can't recreate an issue there.

    Try it with a fresh set of Managers via the New Game Wizard. Add a test item to the inventory with a simple ActionList when Used, and use the default Inventory UI prefab with "Keyboard Or Controller" input. The ActionList runs for me when clicking.

  • edited July 10

    Try also this: in AC's OptionalMouseInputModule script, insert the following into line 95:

    if (raycast.isValid) KickStarter.playerMenus.EventSystem.SetSelectedGameObject (raycast.gameObject);

    What effect does this have on your game?

  • After creating a new set of managers I can select the inventory item and the Use action I assigned works fine. Is there a way I can fix my original managers to work in the same way? Would be a pain to have to recreate them since I have a ton of menus, inventory items, and variables I've built up over the past two years working on my current game.

    Adding that line of code to the OptionalMouseInputModule doesn't seem to have any effect.


  • edited July 11

    Adding that line of code to the OptionalMouseInputModule doesn't seem to have any effect.

    Did you remove it after creating the new set of Managers?

    Is there a way I can fix my original managers to work in the same way?

    Certainly all but your Menu Manager shouldn't be affected.

    Try switching the other 7 back to their originals and try again. If you still have an issue, it's likely some field in your Settings Manager. Then, compare the options at the top of your two Menu Managers. If they're identical, it may be some difference in the UI prefabs themselves.

    No need to recreate anything just yet - just compare one Menu to begin with, to try to see what the difference is - both in terms of the UI prefab and its properties in the Menu Manager.

  • I think I've narrowed it down to an issue with the Rewired plugin I'm using. I can get an inventory item to respond if I am just using Unity's input using the simulated cursor, but when I turn everything on for Rewired that's where it breaks down.

    The OptionalMouseInputModule script you posted doesn't seem to have an affect using Rewired input. I can get the inventory item to respond without it using Unity input.

    I'm using the AC Rewired integration script from the wiki to link Rewired and AC. Don't know if this is somehow getting in the way of the inventory items responding or if it's just something in Rewired itself. Does the Rewired integration script look like it could be cause an issue?


  • edited July 12

    In what way exactly is it not responding? Do inventory item labels appear when hovering over, or is it only that clicking has no effect?

    Rewired is a whole separate input system, that you are using it here is key information. I will look into it further.

    Separately, could you please check the effects of the above code addition when relying on Unity only for input?

  • With Rewired no labels appear when hovering over the item and clicking has no effect.

    When adding the line of code to OptionalMouseInputModule using Unity input I can select the item in the inventory, but while the item is selected the label for the item shows up only for a second before disappearing. Without that line of code I can still select the item and the label shows up and will stay visible. Nothing shows up hovering over the item with or without the code.

  • edited July 13

    Are you using the default UI interface?

    Make sure that your canvas prefab's Label GameObjects (i.e. those with Text components and nothing interactive attached) have "Raycast Target" unchecked - that can interfere with the detection. I will amend the default UI prefabs in this manner in the next update.

    This may also have to be done with the label in the Hotspot UI canvas.

  • Just got back around to looking at this some more. I'm using the inventory Unity UI from the demo scene.

    When using Unity input and when I uncheck the Raycast Target toggle on the label (in the prefab) for the inventory item and I have the added the code to the OptionalMouseInputModule script, I get some weird behavior when trying to select the item. It gets selected, but immediately gets unselected. See video here:
    In the video I am only pressing the button once when trying to select the item.

    When I remove the line of code from OptionalMouseInputModule, but leave the inventory item label Raycast Target unchecked it behaves as expected. I can select it, it stays selected, and the label stays visible.

    Just some extra troubleshooting that might be helpful.

  • Thanks for the update. So unchecking Raycast Target was the solution, as opposed to the script change?

  • Yes, unchecking Raycast Target was the only thing needed.

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.
Do NOT follow this link or you will be banned from the site!