Search Unity

Custom anchor and fractional RectTransform values

Discussion in 'UGUI & TextMesh Pro' started by ortin, Sep 4, 2014.

  1. ortin

    ortin

    Joined:
    Jan 13, 2013
    Posts:
    221
    So I have a custom anchor which tell component to fill 40% of width and in the end I get a RectTransform with width of 454.4. So hence the questions:
    1. Is it OK to have fractional values as RectTransform values(I mean will it lead to some rendering artifacts?)? Note that I have 2D pixel-perfect game with Canvas in overlay mode.
    2. If it's not OK how can I force anchor to take nearest integer number?
     
  2. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    If you enable Pixel Perfect in the Canvas, then the final rects of all elements are rounded to nearest pixel boundaries. This decreases performance in some cases, so should only be turned on if you need it.

    Whether you need it for your game or not depends on the details of how you want your text and graphics to look. It's possible things can look more blurry with Pixel Perfect turned off, but it depends on text size and other aspects of the design.
     
  3. ortin

    ortin

    Joined:
    Jan 13, 2013
    Posts:
    221
    I have Pixel Perfect enabled in the Canvas. Seems bugreport is incoming.
    Oh you mean it's done internally?
     
  4. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    The pixel-perfect option doesn't modify the values in the RectTransform. Only the final rects used for the actual vertices of the Image and Text components. You could say it's done internally, yes.
     
    ortin likes this.