2D Toolkit Forum

2D Toolkit => Support => Topic started by: Jix on January 02, 2014, 09:30:40 pm

Title: tk2dUITextInput scale problem
Post by: Jix on January 02, 2014, 09:30:40 pm
Hello,

I dragged the prefab in tk2dUI_demo/Control Prefabs/Basic/TextInput and created a text input, it works fine but when I scaled it to (250,250,1) a bug happens, I click on the input and start typing but the text is gone and what I type isn't showing.

I tried to scale it to (10,10,1) to see what actually happens, when I click on it and type I can only see the last character I typed... so it must be something related to the scale, help please?
Title: Re: tk2dUITextInput scale problem
Post by: pansapiens on January 11, 2014, 12:59:30 am
I'm seeing the exact same problem here on version 2.3.3 (Unity 4.3.2f1). I'm fairly new to 2D Toolkit, so I could be missing something.

As a test, I resized the tk2dUITextInput within the "2 - UI Layout demo" scene. At scale (2,2,1) the cursor seems to advance the width of two characters when a single character is typed. This means that at large scales (eg x 250) a single character will push the cursor outside the box and you'll see nothing. It makes no difference where the scale is applied (to parent transform, or each child transform).

Any solution ?
Title: Solution to tk2dUITextInput scale problem
Post by: pansapiens on January 11, 2014, 01:23:03 am
I believe I just figured it out.

Rather than scaling the Unity transform, scale individual components of the text input component using the 2D Toolkit "Scale" setting.
eg, the Scale fields on the various tk2dSlicedSprite and tk2dTextMesh components that make up a text input. You may need to manually adjust the local position of the text components a little after scaling.

On the tk2dUITextInput, ensure you increase the Field Length to match your text input - there's a gizmo showing the field length in the Scene view to help.
Make sure you also resize the collider. The quick way is to click on the Collider - Automatic Fit - "Fit" button (on the text inputs tk2dUIItem).

That seems to do it. Now back to making my highscore entry UI  ;D
Title: Re: Solution to tk2dUITextInput scale problem
Post by: gtsphere on January 11, 2014, 04:17:39 am
I believe I just figured it out.

Rather than scaling the Unity transform, scale individual components of the text input component using the 2D Toolkit "Scale" setting.
eg, the Scale fields on the various tk2dSlicedSprite and tk2dTextMesh components that make up a text input. You may need to manually adjust the local position of the text components a little after scaling.

On the tk2dUITextInput, ensure you increase the Field Length to match your text input - there's a gizmo showing the field length in the Scene view to help.
Make sure you also resize the collider. The quick way is to click on the Collider - Automatic Fit - "Fit" button (on the text inputs tk2dUIItem).

That seems to do it. Now back to making my highscore entry UI  ;D

Thank you!  This definitely did the trick, working just great now!