Copying TextField text selection/highlighting to separate script

I’m using Unity to make the front-end for a text-based MUD game and currently have it set up to use TextField objects for the output from the server. Since TextFields are overkill (don’t need any of the editing features, mainly just the text selection/highlight stuff) and they don’t quite play nice with the way I’m wanting things set up, I’m starting with a basic TMP_Text object and cribbing over the methods I actually need to another script. At this point, I can get a highlight over the output text but the issue I have is when OnDrag starts, the text disappears. The text in the actual text object is still there in the inspector and the highlight does get drawn over where the text would be, but the text gets blanked out. (I’ll try to post screenshots here shortly)

I’ve been digging through all the source for the TextField script and it’s kinda over my head as to why it’s happening. Either A) this sort of thing is what usually happens, TextField handles it automatically and I’m obviously missing something so I’m hoping someone could point out to me where TextField handles this, or B) this shouldn’t be happening in the first place, in which case I really messed something up and probably should just start over.

The output I’m testing on is the box to the upper right.


You probably don’t want to do this approach… it’s a big imposition to keep it up to date. It’s always better to use something stock built to purpose (like a TextField) and learn to work with it.

What exactly about TextField doesn’t work for you? You should be able to Instantiate fresh instances of TextFields in boxes perhaps with a prompt and a “GO” button to accept fields of text, and then just stick those instances into a vertical layout group anchored on the bottom that goes upwards as much as you want to keep it.

When you have that working, save it all and move that vertical layout group into a ScrollRect so you can go back on it…

Either way the details of why any of that fiddly diddle user input stuff works is going to have to do with how input is mapped to specific events in an event stream, and how those events are handled… you’d kinda need to reverse everything involved in a text input system to make sure you had it all in there…