Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Text2DAutoFit

Discussion in 'Project Tiny' started by MeTheOo, Mar 25, 2019.

  1. MeTheOo

    MeTheOo

    Joined:
    Dec 14, 2014
    Posts:
    22
    2 Issue I have with Text2DRenderer

    1. Currently, when I added Text2DAutoFit, the text won't display
    2. Without the Text2DAutoFit, the text will display, but the text won't get updated when I change the text.

    I found this in doc:
    "If you want to auto-fit the text inside the RectTransform component, you must also add a Text2DAutoFit component, and make sure to schedule the SetRectTransformSizeSystem."

    here:
    https://docs.unity3d.com/Packages/c...runtimefull_.ut.text.text2drenderer.html#text

    But I am not sure how to schedule the SetRectTransformSizeSystem. Anyone can provide some examples?

    Thanks
     
  2. Rupture13

    Rupture13

    Joined:
    Apr 12, 2016
    Posts:
    131
    Not sure about the AutoFit, but for your second problem, you could try to set the componentData after changing it:
    this.world.setComponentData(myEntity, myTextComponentData);
     
    MeTheOo likes this.
  3. MeTheOo

    MeTheOo

    Joined:
    Dec 14, 2014
    Posts:
    22
    It works, thanks!
     
  4. MeTheOo

    MeTheOo

    Joined:
    Dec 14, 2014
    Posts:
    22
    Any updates for how to get the text AutoFit work? Thanks!
     
  5. Pakor

    Pakor

    Joined:
    Feb 2, 2017
    Posts:
    32
    Could you maybe post a picture of the issue or give more details? When I add Text2DAutoFit it works just fine, so it must be a setting you have wrong somewhere.
     
  6. MeTheOo

    MeTheOo

    Joined:
    Dec 14, 2014
    Posts:
    22
    Yes, when the UI Text has no Text2DAutoFit, it will display the text properly:

    NoText2DAutoFit.png NoText2DAutoFitResult.png

    When the Text2DAutoFit is enabled, the text won't appear:

    WithText2DAutoFit.png WithText2DAutoFitResult.png

    So I found the document here:
    https://docs.unity3d.com/Packages/c...runtimefull_.ut.text.text2drenderer.html#text

    It says
    "If you want to auto-fit the text inside the RectTransform component, you must also add a Text2DAutoFit component, and make sure to schedule the SetRectTransformSizeSystem."

    I am not sure how to implement "schedule the SetRectTransformSizeSystem".
    Don't see any examples related to that logic.

    Thanks!
     
    reallyhexln likes this.
  7. reallyhexln

    reallyhexln

    Joined:
    Jun 18, 2018
    Posts:
    69
    The same problem. Any ideas?

    UPD:
    Depending on the position on the scene, the text may be partially visible, or just not visible, but it always doesn't show on it's own place.

    I think, it's related with RectTransform, but I don't sure.
     
  8. Pakor

    Pakor

    Joined:
    Feb 2, 2017
    Posts:
    32
    Ah! I think I figured it out. Does the text still disappear if you change the min size to below 24 and the max to over 24? When I set both values to the same thing my text doesnt show up either.
     
  9. MeTheOo

    MeTheOo

    Joined:
    Dec 14, 2014
    Posts:
    22
    Just to make sure the size can be fit by auto adjust, so I changed the min size to 1 and max size to 36, but still, in run time it won't display the text at all