Moving the keyboard cursor position to the end of a TextField

I'm working on a chat GUI at the moment and I stumbled across an interesting issue that I haven't been able to figure out. If I use am searching for a particular string and replacing with something else, the cursor stay at the previous location in the string. For example:

chatEntryValue = GUI.TextField(new Rect(y, x, w, h), chatEntryValue);
chatEntryValue = Regex.Replace(chatEntryValue ,"^/s ", "/Squad ");

The resulting cursor position will be (pipe as the cursor position) [/Sq|uad ]

I've tried using chatEntryValue.Remove(1,1) & chatEntryValue.Insert(1,"Squad ") with the same results and even gone so far as unfocusing off the TextField and containing window and refocusing.

Does anyone out there know of a way to move the cursor to the end of the TextField? I'd even settle for simulating Right arrow key presses on the keyboard.

Any help would be appreciated!

This works for me, where s is the string in the text box:

TextEditor editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);

editor.selectPos = s.Length + 1;
editor.pos = s.Length + 1;

late but someone may help. inputfeild.MoveTextEnd(false);

TextEditor te = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl); if (te != null) { te.MoveCursorToPosition(new Vector2(5555, 5555)); }

Looking around, unfortunately there is no way to move the text cursor around inside a Text Area or Textbox. You can get the current position of the cursor, but you cannot set it.

I would suggest this feature be added using the "Report bug" feature inside of Unity. There is an option there for suggesting new features.

And, perhaps, this functionality has been added in Unity 3, which is due out any time now. You could always wait and see if they've included it in there or not. As of right now, though, it looks like this isn't possible.

how do you get the current position of the cursor?

Thanks

So Unity3D 3 is out since a while. Did something change regarding this problem? I've examined the whole scripting-reference but unfortunately found nothing.