Just switched to Unity 5.2 and it seems TextEditor.pos and TextEditor.selectPos changed to something else that I can’t find in the documentation.
There’s only a hint somewhere on the internet that they changed them to TextEditor.selectIndex and TextEditor.cursorIndex but it seems they don’t work the same way they did before, where can I found some information about what’s new with these properties?
Any joy? I’ve run into this too.
Sadly not. For now I’m simply not updating to 5.2 but I’ll investigate the issue further.
I have the same problem.
So finally I’ve got some time to find out whats wrong with these properties.
Actually selectIndex and cursorIndex work just fine but there’s a difference: if your TextEditor is not focused they will return 0! So you’ve got to manage this.
from 5.1 to 5.2 there is a huge unreasonable change.
Yep. This sucked.
Found some luck with the following, but for some reason ended up having to call it twice in consecutive frames to have an effect.
MoveCaretToEnd would be infinitely better than “MoveTextEnd”
//editor.selectPos = cursorPos + 1;
//editor.pos = cursorPos + 1;
editor.selectIndex = cursorPos + 1;
editor.cursorIndex = cursorPos + 1;
editor.MoveTextEnd();
I have the following snippet. From your answers, I cannot figure out how to update my code. Could you help me please?
TextEditor te = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
te.pos = te.pos-1;
te.selectPos = te.selectPos-1;
thanks pawl. that debugged my old project enough to salvage a code from it.