Warning when combining content size fitter and vertical layout group

I followed the Unity tutorial on Scrolling menus at runtime.
It works quite well. However I see a warning, when adding a Content Size Fitter to the scroll panel, which already has a layout group. (In the video that happens around 12:25 and does not merit a warning).

Parent has a type of layout group component. A child of a layout group should not have a Content Size Fitter component, since it should be driven by the layout group.

The warning would make sense to me, if I had the Content Size Fitter on the children of the scroll panel. But the scroll panels size should not be changed by its Layout group at all, or should it?

Is there a better way to achieve a scroll view in newer versions of Unity or is the warning just appearing in the wrong place?

Although this post is quite old, if someone is looking for the solution, it was answered
here

You should set this up with the Content Size Fitter component and the Vertical Layout Group component on the same object. In you’re situation this would be something like

->Scroll Rect Object (with scroll rect component)

—>Scroll Container (Content Size Fitter and Vertical Layout Group components)

----->Scroll content 1 (With Layout Element component)

----->Scroll content n (With Layout Element component)

Hello Everyone

I had a same problem but I used this method.

content (layout & content fitter)

  • child layout1(layout & content fitter)
  • child layout2(layout & content fitter)

  • child layoutn(layout & content fitter)

Code:

int refreshCounter = 0;

void Update()
{

if (refreshCounter > 0)
{
    refreshCounter --;

    if (refreshCounter == 0)
    {
        content .GetComponent<Image>().enabled = !content .GetComponent<Image>().enabled;
    }
}

}

void ChildProcess()
{

//add or remove elements to or from child layout1~n
...

refreshCounter = 2;
//not 1, because after next first frame, the canvas is rendered

}

@baerbel , @phil_me_up , @Black_Demon