Z
Z
Zefirot2021-08-11 11:12:36
Unity
Zefirot, 2021-08-11 11:12:36

How to get rid of the overlay in Scroll View?

The bottom line is simple - there is a Scroll View, it has vertical scrolling, windows as prefabs are already there, but turned off.
When you need them, they turn on, but here's the problem, when you first turn on the windows, they seem to climb on top of each other, if you turn them off and then turn them on as many times as you like, everything will be fine, but when you first open it, this is such an unpleasant picture, and I tried to do this - when clicked on the button to show the window (windows) the method turns on everything and immediately turns off unnecessary ones, anyway the windows will climb on top of each other.
The construction is as follows - Content (vertical layout group, child force expand removed + content size fitter, vertical fit preferred size), prefabs in the content (windows) have the same settings, that is, this is a list with a drop-down list in detail ...
Tell me how to get rid of such a "bug"?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
NoNameDeveloper, 2021-08-11
@Zefirot

https://docs.unity3d.com/2017.3/Documentation/Scri...
- If the layout(grid,vertical,horizontal) group does not work the first time, then you need to rebuild the object on which the layout group component lies.
- This method should be called after enabling.
LayoutRebuilder.ForceRebuildLayoutImmediate(scrollView.content);
Or if that doesn't help, you can use IEnumerator:

private IEnumerator AfterActivate()
{
    yield return null;
    LayoutRebuilder.ForceRebuildLayoutImmediate(scrollView.content);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question