Hello Guest

Author Topic: Difficulty with TK2D UIText Input  (Read 7044 times)

Ezro

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 17
    • View Profile
Difficulty with TK2D UIText Input
« on: March 27, 2014, 01:36:14 am »
Hey everyone,

I’m having a bit of difficulty using the tk2d UIText Input script.
 
I copied the whole ‘TextInput’ game object from the ‘1 - UI demo’. For my project, however, I have scaled TextInput by (400,400,0).
 
After scaling, I am able to see that the ‘EmptyDisplayText’ is displaying correctly. However, whenever I try to set the text to anything explicitly, it’s not visible on my screen.
 
Also, when I click on the ‘InputText’ GO, I don’t see anything listed under ‘Text’. I know that It is storing it, though, since I have to backspace and remove the contents before the ‘EmptyDisplayText’ appears again.
 
Oddly enough, if I were to manually set InputText’s ‘Text’ field, via the Inspector, I am able to see it populate as I would expect.
 
I tried digging through the code, and debugging to see what’s going on when I input text.
From my investigation, it looks like the following line in ‘FormatTextForDisplay’ is always true:
while (inputLabel.renderer.bounds.extents.x * 2 > fieldLength)
 
At this point, I’m not sure what to do. I feel that this is a very minor issue, but am not able to resolve it without spending a lot more time fiddling with it.
 
Does anyone know how to resolve this issue?

Regards,
Ezro

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Difficulty with TK2D UIText Input
« Reply #1 on: March 27, 2014, 10:34:09 am »
Hmm. it looks like it isn't coping properly with the scale. I thought I'd fixed this in a previous version, but it looks like it isn't.

You can get it to behave properly if you don't scale the individual things but rather use the font at the correct size, etc. Or use a second camera for UI so you don't have to scale it. I'm looking into improving the text input control for the next version anyway to make it simpler to use and set up, I'll get this fixed at the same time.

Ezro

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Difficulty with TK2D UIText Input
« Reply #2 on: March 27, 2014, 02:04:51 pm »
Hmm. it looks like it isn't coping properly with the scale. I thought I'd fixed this in a previous version, but it looks like it isn't.

You can get it to behave properly if you don't scale the individual things but rather use the font at the correct size, etc. Or use a second camera for UI so you don't have to scale it. I'm looking into improving the text input control for the next version anyway to make it simpler to use and set up, I'll get this fixed at the same time.

Ah, I see.

Do you know ~when the next version is to be released?

Also, could you please elaborate on the font size correction workaround?

Regards,
Ezro

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Difficulty with TK2D UIText Input
« Reply #3 on: March 27, 2014, 04:25:21 pm »
I can't commit to any release date. Things have never gone to plan when I've done that in the past.

Before I go through the font size / sprite collection thing - why do you need to scale it in the first place?


Ezro

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Difficulty with TK2D UIText Input
« Reply #4 on: March 27, 2014, 05:34:54 pm »
I can't commit to any release date. Things have never gone to plan when I've done that in the past.

Before I go through the font size / sprite collection thing - why do you need to scale it in the first place?

I don't have the project in front of me, but the issue was that when I copied the game object over from the demo, it was a tiny dot on my game's menu screen.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Difficulty with TK2D UIText Input
« Reply #5 on: March 27, 2014, 05:53:35 pm »
OK. What were your camera settings? tk2d UI is built to work out of the box with ortho size of 1 - you can use a tk2dCamera or a normal orthographic camera, and everything should be the right size then.

Ezro

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Difficulty with TK2D UIText Input
« Reply #6 on: March 27, 2014, 11:12:15 pm »
OK. What were your camera settings? tk2d UI is built to work out of the box with ortho size of 1 - you can use a tk2dCamera or a normal orthographic camera, and everything should be the right size then.

Unikron,

I broke everything.  :-X

I realized that I was using an older version of 2D Toolkit (2.1), and upgraded to 2.4.

After upgrading, my UI and buttons stayed the same, but none of my text is readable.

My current setup works as follows:

Tk 2d UIManager holds the UI Camera (Main Camera)
Main Camera is set to Orthographic projection with type 1 pixels per meter.

Not sure how to proceed...

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Difficulty with TK2D UIText Input
« Reply #7 on: March 27, 2014, 11:57:24 pm »
You can fix the corrupted text by doing this:
http://2dtoolkit.com/forum/index.php/topic,3530.0.html
Its a nasty Unity bug.

Your main camera needs to be set to orthographic with orthographic size set to 1, thats the native size for the widgets. If you're still stuck, zip up your project and email to support at unikronsoftware.com

Ezro

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Difficulty with TK2D UIText Input
« Reply #8 on: March 28, 2014, 12:30:04 am »
You can fix the corrupted text by doing this:
http://2dtoolkit.com/forum/index.php/topic,3530.0.html
Its a nasty Unity bug.

Your main camera needs to be set to orthographic with orthographic size set to 1, thats the native size for the widgets. If you're still stuck, zip up your project and email to support at unikronsoftware.com

Ah. That fixed the text issue.

I'm still running into the original issue with the UIText Input, though.

I'll still zip up my project, though, and send it your way.

I think, going forward, all of my UI should be on a scale of 1, using the orthographic size set 1; I'm just not sure what I would have to change in my project in order to accommodate that, though.