[Solved] WorldSpace canvas breaks scrollrect

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.

Aha! Problem solved!

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

1 Like

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.