Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. On February 28th the Feedback website will shut down and be redirected to the Unity forums. See the full post for more information.
    Dismiss Notice
  5. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  6. Unity 2018.3 is now released.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

[5.2] Caret missing in InputField (even in the default one)

Discussion in 'Unity UI & TextMesh Pro' started by CanisLupus, Sep 9, 2015.

  1. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    227
    The caret is always missing in our InputFields since the update to Unity 5.2. The caret object is still created by the InputField and contains the usual Canvas Renderer and Layout Element components, but it simply doesn't show up.

    We can write text just fine, and even select portions, but we cannot see them or where we are writing. If we create a default Input Field from UI > Input Field, it has the same problem.

    Adding an Image component to the caret in Play mode (we tested that manually through the inspector) makes it show up and work as normal. When it shows it still fills the whole text field, but then resizes to normal after we select the field.

    (This question shows the same problem.)

    We assume this is a bug with this release. What can we do? What has changed in order to cause this? The release notes couldn't give us a clue (maybe something to do with UI rendering?).

    Thanks!
     
    XenaWarriorPrincessX likes this.
  2. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,105
    Yes this is a bug that we caught to late i'm working on getting the fix into the first patch right now.

    The issue is the caret needs to specify a texture to use. Give me a min i'm writing a script to help for now
     
  3. EssyTech

    EssyTech

    Joined:
    Jun 17, 2013
    Posts:
    9
    Yep. I just noticed this. Glad its confirmed a bug, was blowing my mind.
     
  4. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,105
    This is dirty but works. The issue is before we would use a white texture if null was specified. This was removed so we now need to specify it to be a white texture (as done here). We are sad it was missed until earlier this week.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.UI;
    4. using UnityEngine.EventSystems;
    5.  
    6. public class SetInputFieldTexture : UIBehaviour{
    7.  
    8.     public InputField inputField = null;
    9.  
    10.     IEnumerator Start ()
    11. {
    12.         // wait a frame such that the caret GO gets created.
    13.  
    14.         yield return null;
    15.         if (inputField == null)
    16.             inputField = GetComponent<InputField>();
    17.  
    18.        if (inputField != null)
    19.        {
    20.            // Find the child by name. This usually isnt good but is the easiest way for the time being.
    21.            Transform caretGO = inputField.transform.FindChild(inputField.transform.name + " Input Caret");
    22.            caretGO.GetComponent<CanvasRenderer>().SetMaterial(Graphic.defaultGraphicMaterial, Texture2D.whiteTexture);
    23.        }
    24.     }
    25. }
     
  5. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    227
    Thanks for the fix. In the meantime I had created something very similar that also waits one frame and them adds an Image component to the caret (I guess the caret gets the texture from the Image in that case). It also works (as a "dirty hack"). :)
     
  6. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,105
    yea i think my way might be better as the image will also want to control the verts of the caret where as the InputField is the one that needs sole control. Not saying your way doesnt work (as obviously it does) but there might be edge cases if the image tries to update the verts itself.
     
  7. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    227
    OK, thanks, I'll keep that in mind and maybe change it tomorrow.
     
  8. yoDon

    yoDon

    Joined:
    Aug 29, 2008
    Posts:
    44
    Any eta on when this patch will appear, or a more robust way of handling the issue than a yielding Start() method? We have lots of inputFields that are procedurally created at run time, which means they don't exist when the containing behavior's Start() method is called. We also have manually placed inputFields that are disabled at start, which means their caret objects don't get created on the first frame of the parent behavior's existence. I tried dropping your test-and-set-the-material code into the Update method of the behavior responsible for the inputFields in hopes of working around these creation timing issues but the inputField appeared to ignore the material changes.
     
  9. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,105
    I'm not sure, the fix has been pushed to the sustained engineering team to get it out to a patch release. I'm not sure which one it will get into.

    As for another function off hand no but moving it to the Update should work just as well.
     
  10. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,105
    Should be fixed in 5.2.1p1 i think
     
  11. Piflik

    Piflik

    Joined:
    Sep 11, 2011
    Posts:
    217
    Did you mean 5.2.0p1, that was released last week or actually 5.2.1p1, which will be released sometime in the future? I couldn't find anything regarding the input caret in the patch notes...
     
    Ferb likes this.
  12. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,105
    might be for a later one, I'm confused as to which release it made it to.
     
  13. _Radagan

    _Radagan

    Joined:
    May 16, 2014
    Posts:
    25
    I updated to 5.2.1f1 today and this problem has only gotten worse. I created a new project, put a input field on a canvas, and no caret or highlight.

    Unity, what's going on? I really need an input field that works!

    I would be happy to send in my example project.

    BTW, a very big thanks to phil-Unity as his workaround still works!
     
    Last edited: Sep 23, 2015
  14. impul101

    impul101

    Joined:
    Feb 8, 2013
    Posts:
    21
    I am using 5.2.1f1 as well and all of my input fields are messed up. I hope for a fix soon.
     
  15. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,105
    Should be out later this week.
     
  16. Piflik

    Piflik

    Joined:
    Sep 11, 2011
    Posts:
    217
    I'm on 5.2.1p1, and the caret is there, but the position is wrong, if the text is not aligned at the top.
     
  17. BrienKing

    BrienKing

    Joined:
    Oct 11, 2015
    Posts:
    30
    This fix does not work for me. Possibly because I am in World Space for the UI Canvas.

    Does anyone have another work around?
     
  18. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,105
    Grab p3 its been fixed.
     
  19. graum

    graum

    Joined:
    May 27, 2013
    Posts:
    7
    I just installed p4, I am still seeing the issue though.

    I get inconsistent results where I'll have multiple fields that are configured exactly the same. Some will work and others will not. I will have to delete them and re-create them and sometimes they will work again.

    Also, if I create a Prefab out of my form with Input Fields and then instantiate at some point while running, the caret does not work at all. Is anyone still having this issue?
     
  20. BrienKing

    BrienKing

    Joined:
    Oct 11, 2015
    Posts:
    30
    Well, I'm using 5.2.1f1, which I assume the p4 is for the Pro Version. So maybe it's broken in the Free Version?
     
  21. Piflik

    Piflik

    Joined:
    Sep 11, 2011
    Posts:
    217
    The p in p4 is for 'patch'. Not limited to pro users.
     
  22. Lone-Coder

    Lone-Coder

    Joined:
    Sep 8, 2012
    Posts:
    59
  23. BrienKing

    BrienKing

    Joined:
    Oct 11, 2015
    Posts:
    30
  24. iivo_k

    iivo_k

    Joined:
    Jan 28, 2013
    Posts:
    312
    Just watching my editor game view in Unity 5.2.2p2 with the caret not visible. Using CanvasScaler with Reference Resolution of 2048*1536. Changing it to 800*600 or something makes the caret visible, which makes me think it's some 1px wide thingy that just disappears when the scale is too large.
     
  25. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,105
    Thats very possible, There should be a change coming to set the caret width in the inspector. Not sure if its being back ported to 5.2 or if its 5.3
     
    Cromfeli likes this.
  26. _Radagan

    _Radagan

    Joined:
    May 16, 2014
    Posts:
    25
    I'm using a CanvasScaler with the same resolution as livo_k and the missing input caret is back AGAIN. I'm using the latest Unity Pro (5.2.3f1).

    When I considered the many cross platform issues I might run into by choosing to go with Unity, I have to say that having a stable Input Field was not one of them! Come on guys...
     
  27. coltonh

    coltonh

    Joined:
    Sep 15, 2015
    Posts:
    6
    So I have been dealing with this issue a lot, and the input field is still not working correctly Unity 5.2.3f1.

    (I have set the texture as @phil-Unity suggested.)

    If it helps anyone solve this issue, I have been able to determine that the input caret is not showing up most of the time on lower quality settings (fast, fastest etc) and that changing the Anti-Aliasing to 2x or larger makes the caret show up more reliably (but still not perfect)

    My assumption is that because the input caret is only 1 pixel wide, when it is between two pixel points on low quality settings it appears to disappear. I have checked this by changing the scale on the input caret game object to 2 or 3, which makes the caret always appear. (but of course in the wrong position)

    This is the only sensible explanation I can think of for why the caret would disappear... 2x + anti aliasing means sampling in between pixels on screen, so the higher the sampling the more chance that the caret will render? (but fainter) This of course is a terrible solution, we shouldnt have to double the amount of samples for the entire game just to get an input caret to appear!

    I find it Really frustrating that the input caret is not actually an accessible game object on its own. If it was actually a GUI image that had adjustable width we could just set the width to be 2 pixels and all have much happier experiences with unity?

    If that is too much to ask, can we just have the position of the caret exposed as a read only variable so we can make our own caret objects that actually appear in the right position with flexible width?


    Sorry if my frustration comes through a bit too strong, but I have literally wasted days on trying to find a working solution for Unity's input fields. As I really dont want to have to build one completely from scratch, I appreciate any efforts from the Unity team to help to resolve the issues with yours!

    Thanks!


    ____________________________________

    Just installed Unity 5.3.0f4 and am stoked to see that there is a slider for adjusting the width of the pixels! As far as I can tell that solves all the problems I am having with the input field caret not working!

    Thanks Unity Team :)
     
    Last edited: Dec 8, 2015
  28. Eb42

    Eb42

    Joined:
    Nov 20, 2015
    Posts:
    1
    My experience with "Caret missing in InputField"

    Unity 5.2.2f1 - DX11 - working in Editor and Standalone in Standalone build
    Unity 5.2.2f1 - GLES3 - working in Editor and working in Standalone build

    Unity 5.3.1f1 - DX11 - working in Editor and Standalone in Standalone build
    Unity 5.3.1f1 - GLES3 - working in Editor and NOT working in Standalone build

    any idea how to fix it?
     
  29. naveen_pambi

    naveen_pambi

    Joined:
    Jan 21, 2014
    Posts:
    9
    this issue still exists with 5.3.2 p3.. any one fix it?

    I'm getting below error while entering text for Input Field,
    OpenGLES error 0x0502 in /Users/--/--/Unity3D/Builds/Feb/15/iOS/Classes/Unity/GlesHelper.mm:339
     
    Last edited: Feb 15, 2016
  30. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,190
    Sounds like something related to GLES. Could you please file a bug report and post the number here.
     
  31. naveen_pambi

    naveen_pambi

    Joined:
    Jan 21, 2014
    Posts:
    9
    thank you for quick reply. Bug report number: 771156_uaog87a215c9s1gp
     
    karl_jones likes this.
  32. KaizerGoreng

    KaizerGoreng

    Joined:
    Jan 20, 2014
    Posts:
    4
    I'm using Unity 5.3.4.f1 and there's a weird issue with the input field. It works fine with the caret showing and I'm able to click on the field and write texts on a testScene that I made. Then when I tried to do the same thing (just placing the InputField on to the scene and press play) on my other scene, it does not work. The caret doesn't show (but is created in the hiearchy), I can't click on the field and can't write anything on it using the keyboard. Any suggestions?

    EDIT: I found out the error is from the scene itself. Something is causing the inputField to not work.
     
    Last edited: Apr 22, 2016
  33. HonkaHonka

    HonkaHonka

    Joined:
    Feb 14, 2013
    Posts:
    4
    Since we updated to 534f1, we have the problem, that on Android in a standard input field, we cannnot see what we are writing. If we however apply the written text. It is written.
    Not sure what the problem may be.
    It is not white text color on white background ;)
     
  34. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,190
    Does this happen in a new project? Can you submit a bug report with a sample project so we can investigate?
     
  35. solarholic

    solarholic

    Joined:
    Jun 25, 2013
    Posts:
    7
    Also with the same problem HERE.
    After I update to unity 5.3.4 P3, I have a problem about typing text in smartphone keyboard.
    It just like some white text in white textarea.
    I can't see what the text I type, but I can see those texts in game.

    Is it the bug?Any solution?

    Thanks
    text_typing_problem.jpg
     
  36. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,190
    Can you submit a bug report with sample project please.
     
  37. solarholic

    solarholic

    Joined:
    Jun 25, 2013
    Posts:
    7
    Hello, I found this is no problem in new project, this problem happen in old project only.
    What can I do?

    Thanks.
     
  38. jackeysee

    jackeysee

    Joined:
    Aug 4, 2016
    Posts:
    2
    I have the same problem.Now,I use 5.3.5p1,new project is ok ,but the project(create in v5.3.1p1) have this problem.
    what can I do?
    Thanks.
     
  39. MattRix

    MattRix

    Joined:
    Aug 23, 2011
    Posts:
    86
    The text caret can still "disappear" in 5.5. I discovered the reason by looking at the source code for the InputField (line 1765). You can't see the caret because the when the caret GameObject is created, it is set to be the *first* child of the Text component's *parent* GameObject. I don't have a clue why Unity did it this way. It seems like a strange decision. It would make way more sense to make it a child of the text component, or at the top of the child order, or next in order after the text area.

    So yeah, the reason you don't see the caret is because it is probably *behind* something else in the gameobject above the textfield. The easiest way to fix it is to insert another gameobject into the hierarchy as a parent of the textfield.

    I'd love it if someone from Unity could chime in to explain the reasoning behind where the caret is placed into the hierarchy, otherwise I think this should be fixed.
     
  40. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,190
    Could you file a bug report so we can look into it please? It could just be a case that we need to change it like you say.
     
  41. ssedlmayr

    ssedlmayr

    Joined:
    Feb 28, 2013
    Posts:
    27
    This error still occurs in 5.6.1f1, and the workaround above does not work - I still see no input caret. There is no way exposed to file a bug report via the IssueTracker, and it can't be reported via the built in bug-reporting tool from the Help menu, because it doesn't fit in any of the pre-defined categories provided by Unity. It isn't an issue with the player or the editor, or a crash or a problem with services. It's a bug in the engine. There is no way for the public to report engine-level issues.

    Please let us know when the actual issue is fixed. I'm working on an input interface in VR using a worldspace canvas and it basically makes it unusable because you never know where the caret is.
     
  42. sambalbij

    sambalbij

    Joined:
    Aug 29, 2017
    Posts:
    1
    I had the same problem where the caret was hiding behind a custom border/background that was a child object of the Input Field object. To solve it you can move all child object except the placeholder and text object (which come with the default input field) to an empty container object.
    Hierarchy:
    • Container
      • CustomBorder
      • InputField
        • InputField Input Caret (spawn the first time the field is selected)
        • Placeholder
        • Text
    I think they set if to be the first sibling because it is also used to highlight selected text and thus needs to be behind the text element. The only possible better place would be between the Placeholder and the Text objects. That would ensure it is drawn behind the text but in front of any other user added objects.
     
    LKWD_JamesD likes this.