Hi Chris:)
Is there any way to show some text when mouse over the Hotspot?
The idea is to show some kind of description text to the area when your mouse over. Let say you have a Sword, so when your mouse over it, you see not just a hotspot label but a short description of this Sword somewhere in the corner.
Same for the items in the inventory. Some kind of examine but in your screen. Any ideas?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
For the hotspots,
if you don't mind using custom script you could use OnMouseEnter() and OnMouseExit()
You could call here an ActionList to avoid futher scripting that would show your menu and set the correct text to it.
You'll need some custom scripting - firstly to hook into events that trigger when the Menu turns on, and secondly to actually store the description text.
Create a new Menu named "Description" and set its Appear type to On Hotspot. Give it a single Label element set to display a Global String Variable value, which we'll update with each descriptive text.
Then attach this as a component to each Hotspot:
Replace the "0" in the script with the string variable's ID number, and write in the Description text in each Inspector.
For Inventory items, create a new String Property in the Inventory Manager named Description, and type this in for each item.
Then attach this to a single GameObject in your scene:
(Setting the "0" values to match your own)
Thank you Chris, it works, but I have some additional questions:
1. Is such description text can be translated then?
2. Also, I see description text on all hotspots even if I am not adding this script to them. But I want to leave some hotspots without this script to let them work as they typically work.
You'd need a different approach, in that case.
Replace HotspotDescription with the following to support translations:
Then place a single instance of the following in your scene:
Error:
Assets/Scripts/HotspotDescription.cs(52,23): error CS0029: Cannot implicitly convert type
int' to
string'Updated.
Hey Chris, buddy, I have some problem with this script. Everything works fine and I see text when I hover mouse on Hotspots, that is really cool. I also can translate it which is also really great! But the problem is that it also shows text when I hover mouse on inventory items. Funny thing is that it display the latest text from the Hotspot where my mouse where on. Please help:)
I shared a script above that deals with Inventory items - are you using it?
How does your inventory appear? Does it turn on at the click of a button / icon, or is it always showing e.g. at the top of the screen?
Yes, I took both scripts that you gave me and did what you said. I did example for you, so let me please show you step by step. Inventory appears type set to "Mouse Over".
I have 2 Hotspots with SetHotspotDescription script attached to both. I also have an empty object in the scene with HotspotDescription script attached to this object.
https://prnt.sc/tieu1v
(explore items set to the right mouse button)
https://prnt.sc/tif99i
When I place mouse over the first hotpost, I see description at the bottomTest 1, which is also correct.
https://prnt.sc/tieuei
But when I go back to my inventory and place mouse over item again, for some reason I start seeing description from the first hotpost Test 1, which should not be there at all.
https://prnt.sc/tieuk8
If I place mouse over the second hotpost, I see description at the bottomTest 2, which is correct.
https://prnt.sc/tieur5
And when I go back again to my inventory and place mouse over item again, I start seeing description from the second hotpost Test 2, which should not be there at all too.
https://prnt.sc/tieuyd
So, this means that for some reason I start seeing description from hotspots at inventory items but I don't want this, cos I already have explore function set to the right mouse button for items. I want to displace description at the bottom just for hotspots but not for inventory items too. I hope that gives you more explanations.
You mean the other way around, no? Each Hotspot should have the HotspotDescription component attached - with only one SetHotspotDescription present in the scene.
If you want the description to only show when over Hotspots, change its Appear type to During Gameplay and check Start game locked off?. Then, try replacing SetHotspotDescription with this:
Oh, cool! It's working now, thank you Chris! Muuuua
The only one thing I've changed was the name of the menu, it should be Description but not DescriptionMenu
Hmm, it seems that I have another issue. Now, when I place the mouse over inventory items my menu is not working. I can open menu but option, load, save and other submenus are not working.
When did this start occuring, and do they work again if you disable any of the scripts mentioned in this thread?
Any Console messages?
There are not any console messages. This start occurring when I changed appear type to During Gameplay. I did a test and set appear type back to On Hotspot and it seems now it's working correct:)
Are things working now? I'm not clear on which menu you're referring to.
Yes, it's working, thank you. I was talking about Description menu.