Search Unity

Blinking Caret sometimes does not appear in Input Field

Discussion in 'UGUI & TextMesh Pro' started by gamefox87, Jun 13, 2020.

  1. gamefox87

    gamefox87

    Joined:
    Aug 19, 2016
    Posts:
    64
    We created a simple chat box. The user presses "Enter"-> blinking caret appears->indicates to user that the field is typeable. They type a message and press enter, the message is sent. Now, they want to press "Enter" again to type another message. The input field is again typeable and the user can type, but the caret doesn't appear. It doesn't appear until the user starts to type. That is, when there isn't any text in the input field, and the input field is typeable, it should show the caret.

    When you press enter, we have these:
    .InputChat.Select()
    .InputChat.ActivateInputField()

    We are using the latest preview version of TMPro.
     
  2. gamefox87

    gamefox87

    Joined:
    Aug 19, 2016
    Posts:
    64
    Any thoughts on this please?
     
  3. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    See if changing the width of the caret has any impact on this?

    Check if the Caret might be outside the view area. Disable the RectMask2D to see if that makes any diffrence?

    Seems like you are using Preview 14 but just in case make sure you use Preview 14.

    If none of the above makes any different, can you submit a bug report with the project and steps to reproduce?

    Please provide the Case # once you have it from Unity via email.
     
  4. MaxLohMusic

    MaxLohMusic

    Joined:
    Jan 17, 2022
    Posts:
    67
    I have the same issue; I removed every single other object from the scene but there's still some "magic rectangle" in the majority of the lower-left screen where if the input field object is placed there, the cursor won't blink; outside of it, it will blink.
     
  5. MaxLohMusic

    MaxLohMusic

    Joined:
    Jan 17, 2022
    Posts:
    67
    I repro'd this on a completely empty scene. How to repro: Add default main camera, default canvas. Canvas scaler, scale with screen size, 1920 x 1080, screen match mode "expand" (AFAIK these are normal settings people are supposed to use). Then, just add a ton of small InputField objects all over the screen. Some are clickable and some aren't. The position at which they're clickable vs unclickable seems to be consistent, but doesn't seem to follow any pattern!

    Edit: Hey good news, looks like the bug is only when pressing play in the scene editor and doesn't repro in a real built game. However, it did cause me hours of debugging frustration
     
    Last edited: Jan 27, 2022
  6. jfaraday1879

    jfaraday1879

    Joined:
    Dec 21, 2021
    Posts:
    3
    With a default TMP Input Field, I got around this by giving the Text child a bit of a left offset
     
  7. daveMennenoh

    daveMennenoh

    Joined:
    May 14, 2020
    Posts:
    107
    Oh Good! Was just looking into this. Still frustrating it happens in the Editor though.
     
  8. daveMennenoh

    daveMennenoh

    Joined:
    May 14, 2020
    Posts:
    107
    After testing this isn't the case. I still get no caret until I type.
     
  9. gaps

    gaps

    Joined:
    Jan 1, 2014
    Posts:
    15
    This seems to be related to the Canvas Scaler.
    The caret seems to be scaled down as well, so if the current scale is small enough, and depending on the position of the caret on the screen, it might not appear. Even in the same input field with some text, placing the caret on a different position of the text is enough to make it appear/disappear (it will be consistent for the same position though).
    I suspect this is because the caret becomes less than 1px wide. The smaller the scale, the more likely this is to happen.

    It looks like a Unity bug to me, and it's still present in 2022.1.23f1.
    @Stephan_B can you confirm if what I'm saying makes sense? And how do we fix it?
     
    gooby429 likes this.
  10. flippi273

    flippi273

    Joined:
    Nov 17, 2018
    Posts:
    24
    I think you might be correct with this. You can see for me it's based on the character you type and the position:

    https://gyazo.com/247b5440c3208cb813eac724b05493e3

    Edit: It will also appear/disappear if I change resolutions of the game

    Edit 2: The only way I can make it work regardless of the resolution and character/position is to increase the caret Width to 4.
     
    Last edited: Feb 25, 2023