Hi, I'm having some trouble with some things related to hovering over items in the inventory.
Firstly, I'm trying to highlight my inventory items while hovering over them with the cursor, as you can see here I have a main and active graphic for each item, but that graphic only shows when i click the item, not when I move the cursor over the item, I thought that would be simple to do but I haven't found how.
Secondly, I want an item description to show besides each item in the inventory also when hovering, kind of like this game but on the left side, so I read some other related threads here like this one (although I only followed the first steps as I got lost afterwards) and ended up sort of managing it. Following that thread's instructions I did the following steps:
1) Created a Menu called "ItemDescriptions". Set it to "Manual" instead of Mouse over, as I'm handling this with events. Created an "label" element. For now I'm leaving this as an AC menu, but I'd like to change it to UnityUI later Here's some images of the menu and how it's looking right now (I didn't manage to make it appear besides the item, so I left it on the bottom center for now, although I'd like to know how to position it like this).
2) Went to Inventory and added Description property as type String. Went back to the menu and finished with this settings: Label type: "Inventory Property". Inventory property: "Description". Inventory Item source: "Mouse Over"
3) Created a newOnMouseOverMenu event and connected an action list that turns on the inventory descriptions menu. Here's this event and actionlist.
So, I did manage to make the descriptions appear correctly while hovering, but not where I want them to.
Also, I noticed I'm turning on the menu but not turning it off, so the label dissapears if I'm not hovering over an item but the menu itself doesn't, the backround remains visible, like this.
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
What are the properties of your Inventory box menu / element?
Check Show Active FX when Cursor hovers over Items in Menus? in the Settings Manager's Inventory panel.
If it's positioned underneath the Inventory menu in the Menu stack, it might be enough to set its Position type to On Hotspot, and then adjust the Position X/Y values to set its relative offset.
Try automating its on/off state by setting its Appear type to On Hotspot. You can lock it when not in use to prevent it from turning on at the wrong time with the Menu: Change state Action.
Thank you! The highlighting works now, and locking/unlocking it + appear type on hotspot fixed the background rectangle staying on screen.
The only thing still not working is the position, the description menu is positioned beneath the Inventory menu in the Menu manager, but the On Hotspot position type doesn't seem to be doing anything. The only position types that are kind of working are Follow cursor and Appear at cursor and freeze, but of course that's not what I want, but I'm not sure how to make it appear besides each inventory item when hovering over them.
Also, there are no hotspots yet, just the menus, but I tried adding a hotspot in order to start working on the interactions in the game and after hovering over the menu items, if i hover over the hotspot the background rectangle shows, I'm not sure why as it's not a menu item, so it shouldn't be getting unlocked by that. I added a breakpoint on the actionlist that unlocks the menu and it doesn't trigger so it's being unlocked elsewhere, I assume it's the on hotspot appear type instead of manual, but if I change ir back to manual then it stops showing everywhere
The On Hotspot position type should work in this case - what are your AC/Unity versions, and can you share images of the two Menus properties?
Unity version 2022.3.5f1, AC version 1.82.5
Here are the images and a video of how it's not working:
1. The item description menu (AC menu, although I tried shifting to UnityUI and it behaved the same way)
2. The inventory menu (UnityUI)
3. Video of what happens when On Hotspot position is used
Besides that, I've been adding some hotspots and logic as you can probably tell from the images and video, and found something else I'm not sure how to fix or work around. I have 2 menus that are blocking interactions with hotspots, I understand this is because of these menus' boundaries, here is the first one, I could work around this by making 2 separate menus for each arrow button, but maybe there's another way? Now, as for the second one this is not the case, because as you can see the boundary takes into account the inventory both closed and open. The ideal scenario for this menu would be that you can close the inventory so only the pocket icon is visible, and then interact with the hotspots that are in that area of the screen, but currently the menu's boundary stays and prevents interactions. Is making separate menus the only way to fix this?
Keep the relative position values at 50,50 - that centers it around the intended position.
What are your Inventory menu's Canvas Render Mode and UI Scale Mode values, and does this occur with AC's default Inventory UI menu? I do not get this behaviour on my end.
A Menu's "RectTransform boundary" will always block clicks to the scene underneath it. You can make this boundary very thin, or off-screen, provided the visible Buttons still react properly to the game's border / aspect ratio.
However, if you have other areas of the Menu that you'd need to prevent clicks (such as the top of the Inventory menu): removing the RectTransform boundary will require you to add a separate RectTransform in your UI to "cover" these areas, and then also check Uniy UI blocks interactions and movement? in the Settings Manager's Interface panel. That will prevent clicks from reaching the scene whenever the Event System detects the mouse is over a UI GameObject.
Here's the canvas info. Yes it does work with the default menu, I hadn't checked before. So I'm not sure why the other one is not working.
Thank you for the info about the boundary! I'll try that
The default InventoryUI uses Screen Space Overlay mode - does yours work if you switch to that?
Otherwise, it might be a case of modifying the default InventoryUI in stages to look like yours - testing each stage - until the issue occurs (or doesn't).
You're right, I changed it to Screen Space Overlay mode and it does work now. I'll be using this mode so I can make it work, but would it be possible to somehow make it work with Screen Space Camera? I sometimes like to play around with post processing effects affecting UI, so that's why I usually choose that mode, but if not it's okay. Thank you!
Update: I changed the descriptions menu to UnityUI using Screen Space Overlay and it's working well, but I have a problem with the hotspots. It seems like even though the Item descriptions menu is locking and unlocking correctly after hovering over and off the items, when I hover over the hotspots the menu is getting unlocked anyway (like this). I don't understand why this is happening, as you can see in the video at first this doesn't happen because the menu hasn't been instantiated yet, but after hovering over the inventory items it starts happening. Nonetheless, the actionlist that unlocks the menu isn't used when hovering over the hotspots (I added an Actionlist: Comment to check), so I don't get it.
How/when exactly are you locking/unlocking the Descriptions menu?
Sorry if I wasn't clear about that earlier. I created a newOnMouseOverMenu event and connected an action list that unlocks the inventory descriptions menu. Here's this event and actionlist.
So, that event and actionlist only get triggered when I hover over the inventory items, which is correct. But as I was saying and showed on the video, the menu is getting unlocked anyway somehow, and not through this event/actionlist.
And you say you've added a comment to this list to confirm its not being unlocked this way?
Open up AC's Menu script and look for the IsLocked property around line 3385. After:
Copy/paste:
That'll output to the Console each time a Menu's locked state is changed - what does it show for your InventoryDescription menu?
Oh, it's only coming up on the console when i hover over the items, not the hotspots, even though the dark rectangle still appears and the hierarchy shows and hides the menu (like I showed on the video). So apparently that's not the issue I guess
If the Menu is already unlocked, it will show when over Hotspots. The Console won't necessary log at the time you hover over Hotspots - but it will show when the Menu is unlocked.
Once it's unlocked, it will need to be locked again to prevent it from showing over Hotspots. Are you locking it as well?
Sorry I couldn't answer you before. I mean... it is locking it automatically I think with the OnMouseOverMenu event or at least that's what I assumed is happening, like if it's hovering is unlocked/it's not hovering is locked. But there's no event to track when you stop hovering over a menu, so I didn't set it up manually because I didn't know how to. Is there a way to do that?
It won't lock itself automatically. Once it's unlocked, it will show whenever its Appear type condition is met - in this case, On Hotspot, which'll be whenever a Hotspot (or an Inventory item) is selected.
One thing you could try is to assign an ActionList in the Menu's ActionList when turn off field, and have this lock the Menu - so that it locks each time it turns off.
Oh wow can't believe it was that simple, sorry for all the fuss. Worked perfectly, thank you!
Hi, sorry to revive this thread but I took some time off the project and now that I'm back I'm noticing that even though that solution seemed to work, the rectangle is still appearing, just only the first hotspot hovered after the inventory item. As you can see in this video, I added a comment to the console each time it's locked like you suggested, and even though it is getting locked, you can see that the menu gets unlocked somehow that first time hovering over the hotspot. Here's the menu and the actionlist when it's turned off.
The console log is only showing "locked" - not the actual locked state as my suggested log should show. If that's the same menu, it's becoming unlocked and showing over Hotspots. You'll need to amend the log to have it report when the Menu is unlocking.
If you can get such a log, that shows at the time it shows for a Hotspot, select it and you can get the full stracktrace for it underneath - what does it show?
Sorry, I tried again with your suggested log and here's a video (and image of the log and stracktrace) showing the console while I do the same actions as before. Apparently it's locking and unlocking immediately and that's why it's happening.
It's coming from your OnMouseOverMenu event - which presumably is correct, if you're unlocking it when hovering over the Inventory menu.
What you need to ensure is that your Menu locks again when you hover over a Hotspot. Do you have a similar event hook into OnHotspotSelect?