I have made a virtual keyboard for a PC with touchscreen and Windows 7 (for a client, a registration form for webplayer - long story), with Unity 4.6.2f1.
I tried to send events to InputFields (as pressing a Button from the keyboard will take the focus away from the selected InputField) to simulate keystrokes and mouse clicks with no success.
So, my questions:
Is there a way to simulate the events which I’m not seeing or it just isn’t possible?
If that is not possible, to create my own InputField component, is there a way to read the current width of the text in the Text component?
I tried reading textComponent.cachedTextGenerator.rectExtents.width and textComponent.cachedTextGeneratorForLayout.rectExtents.width but they’re returning 0 at all times.
In the meantime, I created my own InputField, which works but has some limitations, as I can’t put the cursor between chars as I couldn’t measure the actual text length in pixels.
because the Ui system still uses the old legacy text system, working out text size, position and scale is going to be just as hard as it was with the legacy GUI. Especially when you take in to account that to get the best quality text, you need to have the Rect Area size very large and then scale it down to fit. In those instances, working with pixel sizes will be very hard.
The Inputfield does have a Caret component but not looked to deep in to how it positions it. i suspect there will be no easy answer until the text system is updated.