I was wondering if it was possible to combine elements from two different interaction methods?
See for a while now I've used the Context Sensitive setting in my Unity2D game and had a menu with icons that appears around the cursor to illustrate what actions the left and right mouse buttons do. The icons are made with Interaction elements, so they aren't buttons, they appear based on what actions the hotspot has defined. So if the hotspot has no interactions, no icons appear.
Now I've changed the interaction method to Choose Hotspot Then Interaction, in order to lock the cursor menu in the center of the hotspot so I can click on the icons. But none of the appear types really do it for me - I'd rather the menu appear as I hover over the hotspot instead of having to click once before it appears.
This is totally possible by setting the menu to appear On Hotspot instead of On Interaction, however this means that the context-senstive cursor icons don't work, they are just all turned on regardless of whether the hotspot has an action defined for that particular cursor or not. And on top of that I have a label with the hotspot description to which I append the cursor prefixes, but that also doesn't work in this half-and-half mode.
Is there a way to do this or can these two modes just not really be combined in this way?
Here's a Vine to clarify:
So not all three icons should be active for every hotspot. That's the code that's missing in the On Hotspot setting.
Addendum: the cursor menu, when set to appear centered on a hotspot, displays at the feet of NPC characters with the hotspot script, even though they also have a box collider with the pivot point in the center. Any way to fix that, or define a marker/gameobject within the character prefab that the hotspot should adhere to?
Comments
Inside the OnMenuEnable function, check for the menu in question and call:
_menu.MatchInteractions (playerInteraction.GetActiveHotspot ().useButtons);
PlayerInteraction is attached to the GameEngine prefab, just use a GameObject.FindWithTag (Tags.gameEngine) to reference it.
As for the menu appearing at an NPC's feet, I'll sort that in 1.39.
menu.GetRect ().Contains (playerInput.invertedMouse)
Where PlayerInput is a script attached to GameEngine.
Regarding MatchInteractions, I would put a check in there to see if the active Hotspot has changed. MatchInteractions is an expensive function, so I wouldn't run it every frame if possible.