- Home /
Get The Mouse selected
I use the GUI for UI. Then I want to know how to get mouse now selected gameobject. How to implement this function?
This question has been answered many times. Google for "Selecting a Game Object with a mouse Unity3d". Here is one hit:
http://answers.unity3d.com/questions/411793/selecting-a-game-object-with-a-mouse-click-on-it.html
I want to the input by using GUI.TextField. But I don't know how to judge the cursor is in the input. If the input is selected. And I want to know when the input is not selected!
Read the docs! It returns the text that is currently in the field every OnGUI() call. http://docs.unity3d.com/Documentation/ScriptReference/GUI.TextField.html
Dear, I want to know the cursor is in the TextField, and when the cursor exist the textfield. Because when cursor is in the TextField, when user press some key is invalid!
I reopened the question, but I'm still not sure of your issue. You can test to see if the mouse cursor is above the rect you specified for a text field. You can use GUI.FocusControl() to set the focus to a specific control. You can use GUI.GetNameOfFocusedControl() to see if your textfield has the control.