I'm making an FMV game, which means I always have a video clip playing. Because I'm using RenderTextures to play the videos, they always appears in front of any AC hotspots, thus making them unclickable
I'm tinkering with adding hotspots to a Unity UI which appears in front and over the top of the videos but the hotspots don't seem to work when placed in a Unity UI.
I'm wanting to be able to drag inventory items onto the hotspots and to run and interact/examine action if clicked on.
Is there any simple way to achieve this?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Hotspots require a collider surrounding their boundary to be clickable, and needs to be positioned in world space, rather than screen/canvas space.
I'm not sure why the use of RenderTextures is making Hotspots unclickable, however. Are your RenderTextures being played on a mesh that has a collider? Removing the collider will allow raycasts to go through it.
Is it not possible at all to have them work with screen/canvas space?
Hotspots are not designed for UI. But if there is no collider present, it sounds like the issue is something else.
If you enable the AC Status box, is the game state listed as "Normal" or "Cutscene"?
It's listed as 'Normal.
I've figured out that it's NOT the RenderTextures or the video UIs that are causing the issue, but rather a Unity UI that appears which allows the player to choose where they wish to travel to (screenshot below). There are no raycasts blocking anything and the menu it's on it set to not pause gameplay etc.
It's worth noting that the inventory at the top isn't interfering with the hotspots either, it's just the 'location select' menu.
There are no blocking actionlists running or anything. The hotspots just refuse to be accessible in-game if that 'travel' menu is on-screen. Below are the settings for that menu:
I've tried disabling the Canvas Group in case that was blocking it but that didn't make a difference, apart from making the buttons unclickable.
I think I'd be able to use standard hotspots instead of using them in a UI if I can just figure out how to make them work while that menu is on-screen.
If there was a way for the player to drag and drop inventory onto Unity UI buttons, this would also be an option if I couldn't get the hotspots working.
UPDATE: I fixed the issue above and got the hotspots to be seen - it was an issue with a UI panel which I replaced with a generic GameObject and that seemed to fix that problem.
I only briefly got them working though if I set both the Main and AC camera to Orthographic but that just messes up the positions of the hotspots on different aspects (I can't lock the aspect ratio as the game supports 21:9 so 16:9 videos will play on 21:9 on aspects with no borders at the top and bottom) and if I have them set to Perspective then the hotspots seem to glitch and can be interacted with ANYWHERE on the full game screen, no matter where they're placed in the game scene.
I have all my UIs working perfect on all aspect ratios except the hotspots as they can't be 'pinned' with the usual Rec Transforms that Unity UIs have.
I think my best bet going forward would be to find a system where I can drag and drop inventory items onto transparent Unity UI elements and have them react in the same way a hotspot would, but I've absolutely no idea how to do that. Can I somehow link them to an AC script that takes care of inventory interactions?
This will be a case of the Menu's RectTransform boundary covering the screen. If the mouse if over a Menu's boundary, clicks to the gameplay scene will not be registered.
Add an InventoryBox element with the following properties:
Then link it to a UI Button, and attach the script below, filling in its Inspector with the Interaction data:
Thanks, Chris! I've done that but am unsure about how to check which inventory items have been used on the button?
Looking at the script, I'm presuming once attached to the button it should give me options to select the inventory item's ID and the actionlist to run, but those don't show. It just shows the script as below:
Also, would this still work with a general click without an inventory item that would run an "examine" actionlist?
Try it now.
Thank you SO much, Chris, you're a life-saver! It works perfectly! I'm now trying to figure out how to have it handle unhandled inventory items. I'm thinking there's an 'else if' involved somewhere? I'm useless as scripting