2D Toolkit Forum
2D Toolkit => Support => Topic started by: zblack on July 21, 2015, 04:49:53 pm
-
Noticed that the cursor would not position properly at the end of the entered text when I had the tk2dUITextInput embedded in a slightly scaled down parent object. The fix is to divide the extent of the renderer bounds by the lossyScale of the game object at the end of SetCursorPosition(). I split it into a var with 2 lines just for readability:
float renderBoundsRight = inputLabel.GetComponent<Renderer>().bounds.extents.x/gameObject.transform.lossyScale.x;
cursor.transform.localPosition = new Vector3(inputLabel.transform.localPosition.x + (renderBoundsRight + cursorOffset) * multiplier, cursor.transform.localPosition.y, cursor.transform.localPosition.z);
-
Hi, thanks for that. IT'll be in the next version.
-
Hi,
One more thing needs to be changed to work properly -
in FormatTextForDisplay
float localSpaceLabelWidth = inputLabel.GetComponent<Renderer>().bounds.size.x / inputLabel.transform.lossyScale.x;
while (localSpaceLabelWidth > fieldLength)
{
modifiedText=modifiedText.Substring(1, modifiedText.Length - 1);
inputLabel.text = modifiedText;
inputLabel.Commit();
localSpaceLabelWidth = inputLabel.GetComponent<Renderer>().bounds.size.x / inputLabel.transform.lossyScale.x;
}