Hello fellow adventurers,
I am putting together some basic systems for a hybrid text-adventure style game. There will be the main display of text where the story unfolds, and then the AC inventory system at the bottom.
Essentially, I want the player to be able to interact with certain words, as if they were hotspots. IE, drag a key item from the inventory onto the word 'door' to unlock it.
I am stuck trying to get an interactable hotspot to work within a UI element. I followed this thread
https://adventurecreator.org/forum/discussion/10636/can-i-use-hotspots-in-unity-ui
but that does not let me simply drag an item over the button to interact. The button must be clicked to activate the hotspot, and then, for some reason, the hotspot is registered anywhere on the screen - a click anywhere on screen will interact with the hotspot, rather than only over the specific hotspot element. And then the hotspot cannot be turned off.
Is there a better way to do this? I tried using 3D TMP Text element, which does not use the UI so I could simply put a hotspot over the word I wanted, but I cannot figure out how make a scrolling text (adding a scroll rect) element outside of the UI canvas.
Any ideas? Thank you so much!
Comments
Welcome to the community, @ryanfaelen.
As a fan of text adventures, that's a great idea!
I'd expect the cleanest way to handle this would be to leverage TMPro's link tag to mark your interactive text portions with a unique ID.
This is because TMPro has a helper function - FindIntersectingLink - to determine which link the mouse is currently over. A custom script could feasibly compare this link's ID with one you specify, and run an ActionList if you then de-select a given item while over it.
This may need tweaking, but it's probably something along these lines:
I'd say let's check that it works on desktop first, but otherwise it should just be a case of replacing:
with:
That will have it rely on AC's cursor position, so it ought then to be cross-platform.