Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

InputField caret with Canvas Scaler has wrong size and position.

Discussion in 'UGUI & TextMesh Pro' started by nporaMep, Jun 1, 2015.

  1. nporaMep

    nporaMep

    Joined:
    Oct 31, 2014
    Posts:
    33
    When you use Scaler in Scale with Screen Size and use different than reference resolution caret has wrong size and position.
    I guess problem is in GenerateCursor method as it doesn't take Canvas().scaleFactor into consideration and changes height only if Text's font is Best fit.

    I just started investigating it, maybe someone has fix already? or there is a registered bug in progress?
     
  2. nporaMep

    nporaMep

    Joined:
    Oct 31, 2014
    Posts:
    33
  3. asifoncue

    asifoncue

    Joined:
    Dec 8, 2014
    Posts:
    12
    I'm having the same issue. Will try the latest version in bitbucket, but it'd be lovely to get this fixed in an update.
     
  4. Marble

    Marble

    Joined:
    Aug 29, 2005
    Posts:
    1,269
    Yeah, 5.1f3 still has this bug. Has anyone managed to find a workaround for this until Unity patches? Copying the InputField script and its dependencies into my project doesn't seem to do anything, and replacing the UI system in 5.1 with the built 5.0.2 solution from Bitbucket results in all sorts of UI text fubar.
     
  5. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,906
    Last edited: Jun 22, 2015
  6. Marble

    Marble

    Joined:
    Aug 29, 2005
    Posts:
    1,269
    Glad you found it, Thrawn. How did you reproduce it? I build an empty project and found that new InputFields worked fine, but all my old ones were borked, even if they looked the same in the inspector. I had almost resigned myself to going through and recreating all of my old fields.
     
  7. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,906
    Honestly don't know exactly how. I created an input field exactly with the same configuration and parents like my other project and it worked well! Then I converted it to a prefab, changed font from Arial back and forth, and after one or two reloads, the issue started to occur as well.
     
    Marble likes this.
  8. asifoncue

    asifoncue

    Joined:
    Dec 8, 2014
    Posts:
    12
    That's odd, it happens to me every single time I create an InputField as long as I've put the Canvas Scaler to scale with screen size. Maybe the problem varies depending on the version of Unity?
     
  9. iivo_k

    iivo_k

    Joined:
    Jan 28, 2013
    Posts:
    314
    Whenever the InputField's text size is changed from the default, the caret and highlight color are in the wrong position.
     
  10. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    520
    The same issue after updating to 5.1.1f1
     
  11. Marble

    Marble

    Joined:
    Aug 29, 2005
    Posts:
    1,269
    Still an issue in 5.1.2. :( Where's the issue tracker link for the reported bug so we can pile on? It probably ought to be re-reported anyway. I've done so on my end.
     
    Last edited: Jul 21, 2015
  12. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    520
    yeah.. I didn't find any existing issue about it. Need to create new one.
     
  13. movra

    movra

    Joined:
    Feb 16, 2013
    Posts:
    566
    This was a lovely issue during the indiesvsgamers gamejam. Had to rethink the UI to accomodate for font size 14. Ridiculous.
     
  14. Marble

    Marble

    Joined:
    Aug 29, 2005
    Posts:
    1,269
    I got this response to my bug report:

    While I was hoping for a fix in a patch release, since the issue does horribly break a lot of game UI, at least we can expect a solution by the "next major version," which I presume to be 5.2 on September 8.
     
  15. movra

    movra

    Joined:
    Feb 16, 2013
    Posts:
    566
    Isn't a major version usually the first number? http://semver.org/ By that standard the next major version would be Unity 6.

    But it will indeed probably be Unity 5.2 considering UI improvement is one of the 5.2 beta features.
     
  16. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    520
    So what to do now? That carets are awful. Now it is 5.1.2 and nothing changed
     
  17. Marble

    Marble

    Joined:
    Aug 29, 2005
    Posts:
    1,269
    We've been assured it will be fixed in 5.2. We need to wait for September 8.
     
  18. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    520
    glade is not so far..
     
  19. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    correct the issue should be fixed in 5.2 reason it's not a patch release is that we changed a bunch of stuff in text generation to make the caret positioning calculation more accurate. This sort of major change shouldn't be done in just a patch.
     
  20. Deleted User

    Deleted User

    Guest

    Well, this may be too late of a post, but i managed to find a work around by
    1. Set the pivot of text field to 0,0
    2. Set Text to best fit and give it a same size for both min and max value
    3. Line Spacing to 0
    4. Alignment to top

    You will find the text will float above the text box, Sizing the height of the text box appropriately for the caret to match in middle of the text.

    Cheer,

    sorry if this solution doesnt work for u it does work for me thr ..
     
  21. Spellloop

    Spellloop

    Joined:
    Jan 1, 2015
    Posts:
    2
    Is this fixed in 5.2.0f3 for anybody?

    In my project it has become arguably worse, because now I can't even see the caret. I played around with the values, assuming something I did earlier might be the problem, but even adding an InputField from the menu to a new scene will produce the same result: No caret.

    I've just submitted an issue, because I couldn't find any recent bug report on this: Issue
     
    Last edited: Sep 10, 2015
  22. Xyra

    Xyra

    Joined:
    Jul 18, 2012
    Posts:
    17
    Sort of fixed for me.

    If the Inputfield has an image component the caret disappears. Remove the image (or put it into a parent game object) and the caret reappears but in the correct location.

    Edit: This appears to be an editor issue for me. When built to iOS it correctly shows the caret
     
  23. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
  24. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    520
    5.2 fixed that bug in my case. Now caret in correct position
     
  25. RogDolos

    RogDolos

    Joined:
    Oct 16, 2012
    Posts:
    42
    I would really like to see caret bugfixes backported to 5.1.

    Here's my workaround though (in 5.1.4):

    Set the pivot of the Text's RectTransform slightly off on the X value (so 0.499 instead of 0.5) in the editor and then in code sometime after Start, set it back to 0.5.
     
    Last edited: Oct 21, 2015
  26. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    why dont you grab the fixes from the open source and put it in your project? You might need to modify a few things to have it work but not much.
     
    RogDolos likes this.
  27. RogDolos

    RogDolos

    Joined:
    Oct 16, 2012
    Posts:
    42
    How much would I have to grab and replace to make it work though? Would InputField.cs do? At a glance there's a lot of diff just in InputField.cs between 5.1 and 5.2.

    Also the source on BitBucket, isn't that 5.1.0f1 and 5.2.0f3? Is it actually fixed in 5.2.0?
     
  28. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    with luck I'm going to push 5.2.2 later today.

    really all that would need changed is the rendering portion. i.e. OnFillVBO
     
    RogDolos likes this.
  29. RogDolos

    RogDolos

    Joined:
    Oct 16, 2012
    Posts:
    42
    I just gave 5.2.2f1 a go, but the bug is actually still occurring.

    I have a Canvas scaling with a reference resolution of 1920x1080 (match width). Load up the build and depending on the resolution (1024x768 as an example) the caret disappears. Maybe there are other factors involved, font or whatever, but it's still happening.

    Edit: The (silly) workaround still works, I don't know if that adds insight. Shift the pivot.x of the Text over just 0.001 after Start() (not before or during) and the caret appears.
     
    Last edited: Oct 21, 2015
    _Radagan likes this.
  30. Kamilche_

    Kamilche_

    Joined:
    Jan 11, 2015
    Posts:
    75
    Yeah, this bug is still here in version 5.2.3f1. Did the bug not make it in? I'm just wondering why they say it's fixed. Have a really tall inputbox, and the bug is still there.
     
  31. Kamilche_

    Kamilche_

    Joined:
    Jan 11, 2015
    Posts:
    75
    Marble likes this.