I am using EzGUI but I need a really good text entry component. EZGUI has a text-field but it isn’t good enough. I need one that has caret support and can clip the visual of the entered text to a 2d box. Also I have frequent issues where I need to know how wide the text will be.
As I write this an idea occurs to me that may work so I don’t have to rewrite the out of the box textmesh. I could use 2 3d Text objects, on of them being off-screen. I would use the off-screen one to get the bounds of the text or substrings of the text. When I move the caret (right or left arrow or mouse click) I can increase or decrease the number of characters in the off-screen 3d Text and use renderer.bounds to get the actual bounds. This should give me a good indication of where to put a blinking caret on-screen.
I can use two strings one being the shown string and one being the actual entry string to keep the 3d Text clipped visually within a 2d box area. As the caret moves I adjust the shown string to only have characters that would be within the bounding area
(Using the off-screen 3D text to test this). This wouldn’t be as cool as being able to clip textmesh itself but its plenty functional enough for a text-field entry.
A potential gotcha would be if changing the text for textmesh doesn’t immediately adjust its textmesh.renderer.bounds value. If I have to wait an update frame then that could be very tricky to extract the boundary data (text width) as I expand and contract the off-screen 3d text.
Well thanks for listening to me think out loud. Any other potential gotchas?