Search Unity

Bug UIElement controlled by ContentSizeFitter not registering correct position (for click)

Discussion in 'UGUI & TextMesh Pro' started by jgmakes, Sep 4, 2020.

  1. jgmakes

    jgmakes

    Joined:
    Jan 10, 2019
    Posts:
    75
    I’ve been wrestling with an InputText field that can only be clicked/tapped WAY above its visually rendered area. Check it out:



    The parent canvas has a ContentSizeFitter with everything aligning vertically to the center. If I disable it, the aligned text/input fields snap to the top of the canvas, and the InputField in question now sits with the interactive area and tapping on it focuses the field.

    Here you can see it’s still thinking the InputField as being above (as if ContentFitter were not enabled). The renderer knows to draw it below, but Graphic Raycaster doesn’t know that. Is that possible?



    In the video above I set the InputText's LayoutElement component to "ignoreLayout" so I could demonstrate the connection, but the issue is the same when it ignoreLayout = true;

    I want the group of text fields to grow from the center as the textfield get more lines of text, but clearly this approach of using a ContentSizeFitter has issues.

    Is there a small setting I'm missing perhaps, or does anyone see another way for me to achieve this?

    ContentSizeFitter.png
     
  2. jgmakes

    jgmakes

    Joined:
    Jan 10, 2019
    Posts:
    75
    Success.
    1. disabled the ContentSizeFitter on the parent canvas
    2. set its childAligment to Middle Center
    3. Then I noticed somehow the InputText element had an extra Canvas component on it, so I removed it.
    Now the text is vertically centered with growing inner elements, and the text field can still be clicked on. Still curious why the ContentSizeFitter moves elements in the layout, but only visually, not as far as raycasting is concerned. But my problem is solved.