Draw your own InputField, cursor/selection location

I would like to draw my own InputField control, using 3d objects.

I’ve got the mouse-input working, so I can click on parts of my text to highlight it, and move the cursor around.

Rather than re-invent how the Input field handles keystrokes, given the cursor position, and highlighted text, I would like to use the functionality that is already built into the InputField.

I started by simply hiding the input field, and sending it the keystrokes. Then lookup the resultant text, and display that. This works fine, but has limitations I can’t seem to get around.

The problem I’m hitting is drawing the cursor. Where in the InputField is (Waldo… no…) the cursor? The issue goes in the other direction too, if the user clicks with the mouse, how do I place the cursor at the given character position in the (hidden) InputField, so the next keystoke will go in the right place.

Unable to find the cursor information, I TRIED to create by own input control code. This worked fairly-well, but has a ton of minutiae still left to handle/implement. Then I tried to handle marked-up text (RichText): which quickly became a nightmare of additional minutiae to handle. Surely there is something out there I can use, rather than having to re-invent the wheel.

I’m not MARRIED to using unity input field’s functionality, but whatever code I use should be able to handle the unity Rich text markup.

(p.s. I realize editing markedup-text fields can yield some odd behavior, but I’m ok with that.)

Research: I DID find this answer: Find cursor position in a TextArea - Unity Answers

But it doesn’t seem to work with an inputfield, I guess it’s only for the old GUI? Maybe I’m doing it wrong? I added a script with this function to an inputfield.

void OnGUI () {
        TextEditor editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
        Debug.Log(editor.selectPos.ToString());  //output is ALWAYS zero
	}

Maybe you could try this code, I used this code to select/ highlight text in the content/ textField

 GUI.FocusControl("MyTextField");                 
                    editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
                    //editor.MoveUp();
                    editor.OnFocus();
                    editor.cursorIndex = 25; // cursor start position
                    editor.selectIndex = 56; // cursor end select position

Been so long since I’ve looked at this: looks like
selectionFocusPosition and selectionAnchorPosition are working ok for this. Guess they are new?
https://docs.unity3d.com/ScriptReference/UI.InputField-selectionAnchorPosition.html

I’ll do more tests and post back,