I'm attempting to make specific words in a GUI.Window click activated (text message appears in window, user clicks on one specific word, and an action happens). I've recently found the GUISettings.doubleClickSelectsWord option, but no reference to exactly how it works or how to use it.
How would I use this to enable click activation of text in the GUI.Window. Then, how do I reference in the script which word was clicked so I can make a specific action happen?
asked Feb 20, 2010 at 05:04 PM
I haven't dealt with GUISettings.doubleClickSelectsWord yet, but I suspect that it won't do what you're after. It's used for text fields where the user enters text. Double-clicking on the word would highlight this word just like in a text editor.
I'd probably go for GUI.button and use the words that you need as texture. If you then click on the word, the button registers a click and you can trigger stuff. That would fairly resemble what you're after. Not perfect, but probably more suitable then a text field.
answered Feb 21, 2010 at 03:38 AM
unity's GUI is a litle different from what you see in other GUI packages. you can get the click event of a button easily or you can use toolbars or selection grids but if you need to get the selected word in a textfield it's not easy. you should use GUIUtility and GUI classes with Event class to work with GUIs in advanced. there are two problems. 1 the documentation of GUIUtility is not complete by no means and getting the info about the text in a textfield needs much more effort. you should opentype library and know the font well to understand the size of the texture for some word and ... don't try it :)
answered Jun 13, 2010 at 11:52 AM