Hey, I am currently working on an RPG, and since I am not that pro, I need some help concerning the chat, I have currently a nice and smooth chat system which works the following way: a Player enters something and it gets added to a string which is shown in a Textfield, well and some of you might know these Item-Link features, where you can SHIFT-Leftclick (or whatever the command) items, to add them dynamically into the chat (meaning, a player can click on that item and it opens op the item information or such)… But is that even possible with the normal unity Textfields?
Heres an example from World of Warcraft (I dont like the game, but you should get the idea from it x3 )
It is possible, but not with a function Unity got build in (correct me of i am wrong please).
I do have an idea, you could use the GUIContent to check if the player is doing a mouseover over a linked item, and if that is the case than when a shift+klick is happening, you will know the player klicked that item.
If you give a GUI element a GUIConent, than you can push the content of that tooltip you than have acces to, in a string, it is as easy as :
On that moment you not only know what gui element the cursor is on, but you can use it as a condition in any function you have. You can for example even change GUI.Labels into buttons if you would wanted to.
If you have a Gui.Label with the content set to “IAmAGuiLabel”, than you could use something like :
If(Input.GetKeyDown("Fire1") && toolTip == "IAmAGuiLabel"){
// do something;
}
This idea will work, but it has a drastic downside. The GuiContent is placed over the entire GuiElement, and not just a piece of the String. So this clickable piece of text will require a new GuiElement to work, and this could be rather annoying if you want to link the item in the middle of a sentence.
Just use NGUI. It’s the most popular GUI framework out there, and has a free version for you to try out. Unity GUI is slow, not WYSYWIG, impractical and will anyway be soon replaced by a new system developped by the NGUI guy, so you’ll have to learn his way of doing things sooner or later anyway.