• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Jeff Lowe · Feb 20, 2010 at 05:04 PM · guitextwindow

Mouse click selecting word in GUI

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?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Sebas · Feb 21, 2010 at 03:38 AM

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.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jeff Lowe · Feb 22, 2010 at 10:29 PM 0
Share

If double-clicking word in the text field selects the text word, how do you access that word in the script, or is there a way? I would love to hear form someone that has used this command too.

avatar image Sebas · Feb 22, 2010 at 10:54 PM 0
Share

The text field is still intended for the user to manipulate the string. I doubt it's useful for displaying a string and having the user click on something. From the documentation you can only access the complete string of the text field, not the "highlighted" substring. If somebody has experience with using a text field for such purpose, I'd be keen to hear that as well.

avatar image
0

Answer by Ashkan_gc · Jun 13, 2010 at 11:52 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 :)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Is the GUI text still viable? 1 Answer

Can't destroy an arrray with GUI Text 2 Answers

Playing multiple sounds with multiple subtitles 1 Answer

Gui Button Solid 2 Answers

GUI & GUI Text Disappear When Publishing 6 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges