Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

[Solved] WorldSpace canvas breaks scrollrect

Discussion in 'UGUI & TextMesh Pro' started by Chris-Herold, Oct 23, 2015.

  1. Chris-Herold


    Nov 14, 2011
    When i change my canvas to world space, scrollrect contents are not properly transformed.

    First i thought they are empty, but it turns out they are perspectively distorted.
    I can scroll, but the content is not correctly projected in 3d, which makes all scrollrect contents appear empty (they arent, the content is just anywhere but where it should be on the canvas)

    Anyone else having this issue?

    - Happens in 5.2.2f1
    - Forward rendering, canvas is not rotated nor scaled.
    - doesnt matter if Rect2DMask or Mask is used, both have the same result
    - even without any mask, same issue. its def. related to the scrollRect rather than masking

    Some findings:
    I've looked at the content children in the inspector, and they all had strange rotation and position.z values.
    Setting rotation to 0 and position.z to 0 fixes it.
    How do the child controls get these strange values?
    This only seems to be a problem with elements that were added at runtime.
    Things already on the canvas when the game starts don't have this issue.
    Last edited: Oct 23, 2015
  2. Chris-Herold


    Nov 14, 2011
    Aha! Problem solved!

    child.SetParent(scrollContent, false) did the trick.
    I didnt realize it's true by default :)
    A bit strange that this only becomes a problem when using WorldSpace canvas, in any other mode the layoutcomponents work just fine.
    rgyger likes this.
  3. lisy_a


    Nov 5, 2015
    I'm sorry, but can you expand on your fix a bit?

    I've got the same problem and I'm not sure how to use the fix you've found.